First of all still very proud on this nice design made by my friend ! It was a good development kit to learn all things on the AVR. So the master was ment to be a target to change some slave parameters using my own one wire protocol. The purpose was to us the OLED display to give in the values. My one wire code was finished first and it coudn't test time being. But as soon as I implemented the slave state machine I finally could see the results. At first it was a bit tuning but after all that the concept worked
very quickly without any major problems. On the picture you can see the master standing right next to the OLED display. At the right of the master you can see my 2 slaves. Again for any code snippets on the one wire refer to my code corner because this blog is not the place to format code in.The second picture shows the OLED graphics. Programming it was fairly easy to do. The first step you need to do is transfer the init code out of the datasheet into your C code. Next the start of the init snippet:
// init the ports
DDRC = 0b11111111;
PORTC = 0b11111111;
DDRB = 0b00011111;
PORTB = 0b11111111;
DDRA = 0b11100000;
PORTA = 0b11111111;
PORTB = 0b11111110; // reset the oled
_delay_ms(1); // spec says wait a bit here
PORTB |=0b00000001; // unreset the oled
// general init commands out of spec
// TODO must be documented in detail
write_oled_command(0x02);
write_oled_data(0x01);
....
I wrote some helper functions for writing the command and data bytes to improve the readability of the code. When you succeed in the init the OLED will give you a screen full of noise pixels but at least you sure it's working. The purpose of the OLED screen was to give the user the ability to do some general parameter set up for the slaves. So I started to think on a possible interface for the little 160x128 pixeels display. The idea came up to use icons as a menu system. Of course the icons we all know on our computers today haven't the right format for the display. No problem for me as I can write some simple python scripts. I wrote a script that converts a extension ICO file to some raw binary data for the display. Code can be viewed at my code corner. With this script I can transfer 16x16, 32x32 or even 48x48 size icon files. The icons must be in 24 bit RGB although I have only 18 bits the last 2 bits are simply not taken into account. I only take the RGB data without the transparency information which I don't need. You can see the result of a converted 32x32 icon on the picture. This format suits very well and I can get 5 icons on one row and I have 4 rows so 20 icons in total. My intention was to draw a red rectangle over the icon to notice the user it's selected when using the 5 function mini joystick which is positioned right under the display. The only limitation I had was the amount of program flash to put in the raw icon byte arrays. I used the special gcc #pragma to locate the array into flash like this:
const uint8_t PROGMEM icon[3072] = {
0x3e,0x9a,0xde,
0x99,0x00,0x00,
0x99,0x00,0x00,
0x99,0x00,0x00,
0x99,0x00,0x00,
......
So as you can see a 32x32 icon takes already 3072 bytes in flash. But still possible to play with 15-18 icons depending on the program code size. To build a rich user interface this is definitly to less. I didn't wrote any code for the mini joystick as I was busy on the move from AVR to CORTEX. So that will be postponed to my new master based on the CORTEX core. Also here the STM32 offers a wide variety on targets that can have up to 512k on program flash. Indeed with 512k bytes you build a much nicer user interface for this oled display than with the AVR. Playing around with 80 different icons is no problem at all. That's basically it what I needed to tell you on my AVR experience.
I linked the TRIOS blog project on this target but in fact it's not quit correct anymore as I 'd changed my target now to ARM CORTEX. I decided to continue in that blog rather than here because all I will write next will be very closely linked to the CORTEX. So please for follow up on this reffer to:
http://guyvo-cortex.blogspot.com/
As the concept gets more and more to it's final stage now, it becomes time to build the PCBs. Due to the fact this has nothing todo directly with software I will open a brand new blog for it as soon as the first layouts starting to get some shape.
http://guyvo-dimmers.blogspot.com/
Enjoy !
No comments:
Post a Comment