@Moonbrain, simply connecting your PC to the Photon USB will create a virtual serial port on the PC. You can then use something like Putty or TeraTerm to open a terminal and connect to the serial port. All Serial.print()
commands will print to that serial port. No need for openOCD.
@peekay123 I’m on a MAC so I use coolTerm. I don’t get anything
@Moonbrain, the serial output may come too fast if coolTerm is not open and ready to receive. There is a commented out statement at the beginning of setup()
that you can uncomment. This will force the Photon to wait for a key to be pressed on CoolTerm before continuing:
// Uncomment line below. When you reflash, open Coolterm and press any key.
// while(!Serial.available()) Particle.process();
I am assuming you have the lily128.bmp file on the sd card. You may want to open the file to make sure it is not corrupted.
I had to switch in my project from a SSD1309 128x64 B&W display to SSD1351 128x128 16-bit colors one. Move was easy but I missed the bitmap loading function in the driver (the existing one is only monochrome).
So reading this thread and looking online for a description of the BMP format I decided to isolate the bitmap loading function in a dedicated class, called… Bitmap.
The main difference with the original function used for the demo here is, I’m reading a native 16 bits Windows BMP, not a 24-bits, so I don’t have to do any color conversion/adaptation. Saving in 16bits colors (565-color coding scheme) should be present in most picture editors (it is at least in GIMP and Photoshop) and since you will probably have to downscale a picture from a huge size to 128x128, why not directly saving in the format the display likes?
This said, since it is a class, everyone will be able to add to any kind of conversions, adjustments, cropping or else they like. I’m publishing the class in my github repository here: https://github.com/peergum/Bitmap
I’ll add a quick how-to guide shortly.
PS: for the note, the picture won’t look as good on the display as on your computer, due to the different pixel density on both displays. I’ll try some experiments to adjust the color scheme to get a closer appearance - still waiting for my display to arrive (been working on a remote display to get that code running…)
Update: after checking it works fine, I made it a public Particle library, so if you need it, just search for “Bitmap” and you should find it
Hi - I’ve read this entire thread at least 5x over and tried most of the implementations mentioned with mixed success and not once have a gotten a full bitmap to display.
The most success that I had was following @peekay123 and @Moonbrain and trying what you had discussed. I got several variations on the “snowy screen”, some that had an extremely partial image (line of blue or similar variants) - after trying this, I moved over to other displays and have successfully gotten a couple of more simple text displays to work via I2C. SPI doesn’t seem to have much support so probably not going in that direction.
To give a little more context, my goal is to try to get a low cost implementation of an OLED Display for the benefits of OLED viewing angles and brightness, but am willing to consider LCD. The cost piece because I am aiming to make this a widely supported community project with a large library of easily useable bitmaps in the appropriate format and working towards selling prototype, but obviously I’m miles from that. The reason I bring up pricing and usability here is because I’m not certain that this display is the cheapest implementation of graphical bitmaps (or any other type of graphics) with photon on small displays due to dependency on SD card (in some variants) which seems unnecessary seeing as the Particle memory can hold enough data for a few bitmaps if used correctly.
note: Also trying to use with a lipo battery so I am trying to account for power consumption if that matters. 1-2 inch size, really like the 1.5’ form factor, if thats helpful to know.
Anyways, my question is, given my goals - and in general, what is the best display that you would recommend? From my research it seems like this is the simplest graphic display to use with particle photon, but I’m sure that there are more widely supported graphic displays for Arduino that could be ported over without that much difficulty.
Really hoping that peekay123 / @MikeSeeH / @ScruffR can weigh in, or anyone else with decent experience with displays on photon / others from this thread, please weigh in, as I was really pursuing this particular implementation for a weeks+ straight (as somewhat of a new person to all this tech but not completely a novice) and I wanted to back up for a second and see if I can get some more insight/ get pointed in the right direction before I go down too far down this rabbit hole.
If folks do agree this is the most supported / most practical setup for a graphical display on photon then I will be happy to try again and provide the Serial.print() debug message if anyone wants to help me through this. Given the recent updates in the particle ecosystem since this thread, I will mention that I have preordered a number of Xenons and an Argon in the hopes that this will help reduce complexity and cost in the short/long term with this project, and would be happy to hear any insight regarding the use of displays with the next generation Particle products - even if the feedback is that that won’t work at all and is a terrible idea.
Thanks for any advice in advance, cheers.
Edit: This is my first post and I carefully read the guidelines at https://community.particle.io/guidelines - If this is technically breaking a rule according to the “Keep It Tidy - Don’t divert a topic by changing it midstream” rule, I apologize if so, I will be happy to delete this post and post it again as a new forum post.
@RTHyman, thanks for posting! Choosing the right display is only part of your total solution. Here are some questions that can help us better help you:
- Does the display need to be color or monochrome?
- What resolution does your solution require?
- Is refresh speed an issue (e.g. animation)?
- Are you looking for a complete display “unit” or a board-mounted version
- Will you be using other Photon GPIO for sensors, etc/
- Will the Photon be mostly sleeping to conserve power?
- Is the display required to be ON all the time?
- How long are you expecting the battery to last before recharging?
In regards to using an SD card, these can be quite power hungry. Have you considered using an external flash to store your images? New images could be downloaded to the Photon over HTTP/TCP for example. If you do use an SD, you may want to consider controlling the power to it using a low-side FET controlled by the Photon.
I look forward to your answers!
@peekay123 thanks for the response! Will do my best to answer these questions intelligently however - fyi my general approach is to try to find as many ready-made solutions as possible, while I have spent a few years casually in the hobbyist electronics diy space my professional background is in social science and human resources and I am doing this alone so still have lots of self education to go.
Also to explain further the use case, I am trying to design a solution for "wearable social media icons", for example you could be wearing it around your neck or wearing it clipped to your shirt pocket, and it would display an emoji (smiley face, pineapple, etc.) - this would be to wear out to events, parties, music festivals, etc.
Does the display need to be color or monochrome?
Color for sure
What resolution does your solution require?
Very flexible with this requirement.
128x128 pixels / 16bits I think is the sweet spot (which is why I like the display in this thread)
I think I could go as low as 8bits and it would still work. Priority here is really battery life. If I could do higher resolution at a low cost and without battery suffering too much that would be amazing but trying to set realistic expectations here. Highly pixelated is ok - don't mind a "retro" look with extremely oversimplified icons/images. Nothing complex, solution is not meant to display actual photos.
Is refresh speed an issue (e.g. animation)?
Yes but not high priority - I am planning to have a button on the side that will allow you to scroll through images, at the very least. So the refresh speed between different icons would be a factor. Would be interested in working towards having 1-2 second animated gifs, or at least having the potential to implement that, however for a first iteration trying to keep it very simple, just low resolution still image icons.
Are you looking for a complete display “unit” or a board-mounted version
Not 100% I understand this question. For complete display "unit" - Not sure if you mean buying a pre-designed "prototype" and then developing on top of that, or buying the display by itself, vs. buying it pre-mounted onto a board.
Definitely not trying to buy a pre-designed product and build on top of that if thats what your asking, since the costs would be too high. Not sure if this is answering the question but my process has been to start with more well supported products (Adafruit displays, such as this I2C board Monochrome 128x32 I2C OLED graphic display : ID 931 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits) and then buying from a cheaper vendor (going to Aliexpress and finding a similar cheaper version - I think my answer then would be board-mounted to start and then my goal would be to work towards buying the display direct and design my own pcb, eventually, if that makes sense.
Will you be using other Photon GPIO for sensors, etc/
For now, very few. Just 1 for power button and 1 for button to scroll through images (hit the button, plays the next image in a given image set, something like that). May want to have more GPIO capability down the road for camera, sensors, but not thinking in detail that far ahead. Should be able to power it through VIN to a lithium ion if I understand correctly.
Will the Photon be mostly sleeping to conserve power?
Probably not mostly sleeping while in use depending on how implementation would work - if the display is powered through the Photon, then it will need to be on a lot. If there is a way to power it separately while keeping the form factor small, that could be worth considering, but I am imagining that both the Photon and the display will need to be able to be on for long periods of time. Which is why I said image resolution would likely be pretty low.
Is the display required to be ON all the time?
Yes, the product itself would be explicitly for putting on displays and wearing them for long periods of time at time, 30 minutes absolute minimum to work as proof of concept I think, but optimistically hoping that I can run it for upwards of 1-8 or 12 hours off of a lithium ion battery (all packaged together in a 3d printed case I will design) somewhere around 1200 mAhs - 2000 mAhs, probably unrealistic but thats my hope
How long are you expecting the battery to last before recharging?
1 use case in my mind would equal one day or one night out at a social event, so same as above, anywhere from 30 minutes to 12 hours would be viable, I think the ideal realistic balance as far as actual use would sit somewhere around 2-8 hours, with 4-8 hours being the sweet spot goal for a first prototypical run of sellable products. As far as recharging goes, am hoping to be able to integrate something like the adafruit powerboost 1000c into the solution.
In regards to using an SD card, these can be quite power hungry. Have you considered using an external flash to store your images? New images could be downloaded to the Photon over HTTP/TCP for example. If you do use an SD, you may want to consider controlling the power to it using a low-side FET controlled by the Photon.
I definitely do not want to use an SD card if it is going to be a power hungry solution. I think it makes perfect sense to use the Particle flash storage, especially since the images would be small low resolution icons, I am hoping to be able to fit around 5-10 images at a time to the flash memory on the photon and then use the button connected to GPIO to scroll through those images. Note here that in this context my short term goal would be to figure out how to HTTP/TCP images onto the Photon and then long term goal would be to figure out how to automate that process and package it into an App through a service like Blynk
Honestly I don't even understand how controlling SD via low-side FET controlled by the Photon would work at all, not familiar with FET at all, could learn more on this if you strongly advise this direction but from my understanding I don't think SD makes sense for this solution, especially given that I think the newer Particle.io mesh wifi chips will have even more flash memory meaning that this would translate well if I want to migrate to newer chips.
--
Again, I've been approaching this iteratively in my free time so I've been kind of aggressively testing / learning about different parts of the solution at different speeds so while some things I've thought out more and might make more sense, others might not make any sense at all or I might not have much perspective on it, so I really appreciate your patience with me and any insight you can offer! Thank you!
@Ryann, I need to review some facts with you on your requirements.
-
A 128x128 16bit (color) image takes 32KB of storage. There isn’t enough flash in the Photon to store more than one image. So 5-10 images can take up to 320KB. External storage is NOT an option.
-
Battery life will be primarily dependent on the the use of WiFi on the Photon and the brightness of the LCD backlight. With WiFi turned OFF, the Photon will typically draw about 80ma. Assuming 50ma for the display backlight, that makes for a total of 130ma. Using a 2000mA/h battery, you could run the unit continuously for 2000/130 * 0.7 = 11hrs. The 0.7 factor is there since the battery can’t be discharged completely. Either battery will fit your 4-8hrs sweet spot.
-
A display “unit” is like the type you would buy from Adafruit like this one which is 240x240 and has an onboard SD socket:
A board-mounted or “raw” display is the type you will find at buydisplay.com like this one which has a flat cable which can be soldered directly to a board or use a connector.
The type of display you use will be driven by your target volume and costs.
@peekay123 Ok sounds good.
A 128x128 16bit (color) image takes 32KB of storage. There isn’t enough flash in the Photon to store more than one image. So 5-10 images can take up to 320KB. External storage is NOT an option.
Makes sense. Just to double check, particle datasheet (https://docs.particle.io/datasheets/photon-(wifi)/photon-datasheet) shows onboard flash as 1MB, however using more than 32KB of that on images wouldn't work is what you're saying - due to the fact that the onboard flash needs to be used for the actual code/processing, right? I think for the purposes of continuing this project I will follow your advice and direction. But I do want to note that the Particle Argon IoT Network Solutions — Products & Services | Particle has [4MB flash for ESP32, 1MB flash on Nordic, and On-board additional 2MB SPI flash] so would that possibly be viable down the road possibly?
Battery life will be primarily dependent on the the use of WiFi on the Photon and the brightness of the LCD backlight. With WiFi turned OFF, the Photon will typically draw about 80ma. Assuming 50ma for the display backlight, that makes for a total of 130ma. Using a 2000mA/h battery, you could run the unit continuously for 2000/130 * 0.7 = 11hrs. The 0.7 factor is there since the battery can’t be discharged completely. Either battery will fit your 4-8hrs sweet spot.
Excellent news, thank you for helping me with these calculations.
A display “unit” is like the type you would buy from Adafruit like this one which is 240x240 and has an onboard SD socket:
Ok this makes sense.
A board-mounted or “raw” display is the type you will find at buydisplay.com like this one which has a flat cable which can be soldered directly to a board or use a connector.
Again, very helpful. Yes, it will be my goal to eventually move towards a "raw" / board-mounted display, but I am definitely not at that level yet, just trying to pick the first iteration in a way that will allow me for the possibility of expanding that way as seamlessly as possible.
So to be clear I would say yes it makes the most sense for me to start with a display "unit". Thank you happy to clarify anything further I can
The Photon's STM32F205 processor does have 1MB of flash. However, the flash is allocated into DeviceOS, key storage, EEPROM emulation and finally, user app (128KB). This is explained here:
https://docs.particle.io/datasheets/photon-(wifi)/photon-datasheet/#memory-map
A similar layout of the 1MB flash will apply for the Argon. However, the external 2MB of flash will be available to the user. The ESP32 flash will not be user accessible.
So, for the Photon, external storage is needed
Thank you for your excellent insight. I will try to wrap up my concrete direction on displays given our discussion and request a little more guidance as far as the software side, as this is where our discussion started. While I am interested in using the new devices I do want to keep making progress for now with the Photon
Display will be using either LCD or OLED (I prefer OLED but from our discussion I am guessing that LCD is more common and that I should perhaps go in that direction), require an SD card for this version, and use a display “unit” (as opposed to raw display)
Adafruit 1.8 Color TFT [https://www.adafruit.com/product/358] is what I started with, the 1.8 inch version of what you recommended, [https://www.adafruit.com/product/3787] - might be best to use one of these LCD screens due to:
-SD card
-LCD implementation (might be easier than OLED?)
The only obvious alternative would be the display used in this thread, [Adafruit OLED Breakout Board - 16-bit Color 1.5" w/microSD holder] or other similar OLED + SD card displays
Other than that, from a software standpoint, to my novice understanding I2C appears easier to implement (thread I successfully followed and was able to get it to work using: Adafruit SSD1306 [SOLVED]) however I2C with photon does not appear to have bitmap support? Or at least I haven’t been able to find examples of it.
This post we are in now specifically targets image displaying through SPI so I know for a fact that images through SPI on Photon is possible I just haven’t managed to do it myself. There is an interesting webhooks implementation that I’m not sure would be worth considering (https://www.hackster.io/weatherornot/photon-weather-display-cb8a90)
In any case, beyond the display itself, it appears I am trying to find any advice regarding the best (easiest / most utility surrounding use of images or groups of images / most photon-centric) implementation guide for getting images onto a display (with SD card) using the Photon. If you or anyone has any more insight on any particular guide/section within this thread or around the internet that might help me use images successfully on the Photon, I would appreciate it. Also would be interested in anything from the Arduino world and other similar platforms that might help me but as I’m still a beginner most likely Particle specific guides would be more appropriate.
If my suspicion (that this is the most in-depth forum post on this exact topic on the internet) is correct, then I can simply proceed to try again with the exact implementation that is discussed in this thread (or one of its variations) and then post the debugger output and see if I can get further guidance.
Alternatively it seems like trying out an LCD display implementation (as the one you provided) might be another logical choice, but not sure if that is more supported than OLED.
Thanks again for your insight and invite any further comments/questions/advice but I do recognize that there is a certain level of self-education and testing I will need to do “figure it out myself” so I will do my best to try and get something working and go from there!
@RTHyman, OLED will cost you more than LCD. However, it will be lower power because it doesn’t need a backlight. Adafruit has this one:
It comes with and SD socket and has libraries to display BMP images from SD that can easily be adapted to Particle.
I recall that @bsatrom at Particle had built some badges for the last Maker Fair that used an Electron and rotated images from an SD card onto a color LCD which, if I recall, was 320x240. Perhaps he can share the code?
Thanks @peekay123, happy to help!
@RTHyman we did indeed use a TDT w/ SD on the first iteration of the PartiBadge. The current version uses a smaller, two-color OLED w/o an SD, so you’ll need to step back a bit in the history of the project to see what we did.
The bmpDraw file has some of what you’ll need, I expect. You’ll need to include the SDFat library, and here’s an example of where where pulling bitmaps from an SD and displaying on the screen.
Hope that helps!
Brandon