Routines to talk to Sure electronics seven segment displays. More...
Functions | |
uns8 | sure_7seg_convert (uns8 digit) |
void | sure_7seg_setup () |
Setup ports and pins to communicate to Sure display. | |
void | sure_7seg_write_str (char *data) |
Display ASCII string to 7 segment displays. |
uns8 sure_7seg_convert | ( | uns8 | digit | ) |
00048 { 00049 switch (digit) { 00050 case ' ': return 0; 00051 case '0': return 0xfc; 00052 case '1': return 0x60; 00053 case '2': return 0xda; 00054 case '3': return 0xf2; 00055 case '4': return 0x66; 00056 case '5': return 0xb6; 00057 case '6': return 0xbe; 00058 case '7': return 0xe0; 00059 case '8': return 0xfe; 00060 case '9': return 0xf6; 00061 } 00062 }
void sure_7seg_setup | ( | ) |
Set up ports and pins as appropriate to communicate via SPI to Sure 7 segment displays
00043 { 00044 spi_setup(); 00045 }
void sure_7seg_write_str | ( | char * | data | ) |
Converts ASCII to the appropriate magic characters to display on a Sure 7 segment display. Only numbers 0-9 and space are implented for now.
To create your own characters, add together: 0x40 -------- | | 0x02 | | 0x20 | 0x01 | |------| | | 0x04 | | 0x10 | | -------- 0x08
00064 { 00065 00066 uns8 count, digit; 00067 char converted[5]; 00068 00069 count = 0; 00070 do { 00071 digit = data[count]; 00072 converted[count] = sure_7seg_convert(digit); 00073 count++; 00074 } while (count < 4); 00075 spi_write_sure(converted[3]); 00076 spi_write_sure(converted[2]); 00077 spi_write_sure(converted[1]); 00078 spi_write_sure(converted[0]); 00079 00080 clear_pin(spi_clk_port, spi_clk_pin); // set to low 00081 set_pin(spi_clk_port, spi_clk_pin); // set to high 00082 00083 }