valjda je to to
Dependencies: BSP_DISCO_F469NIfdsf LCD_DISCO_F469NI mbed
Gear.cpp@0:a549a6b9b62e, 2017-10-23 (annotated)
- Committer:
- formulas
- Date:
- Mon Oct 23 15:07:35 2017 +0000
- Revision:
- 0:a549a6b9b62e
pokusaj1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
formulas | 0:a549a6b9b62e | 1 | #include "Gear.h" |
formulas | 0:a549a6b9b62e | 2 | #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" |
formulas | 0:a549a6b9b62e | 3 | #define BYTE_TO_BINARY(byte)\ |
formulas | 0:a549a6b9b62e | 4 | (byte & 0x80 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 5 | (byte & 0x40 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 6 | (byte & 0x20 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 7 | (byte & 0x10 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 8 | (byte & 0x08 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 9 | (byte & 0x04 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 10 | (byte & 0x02 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 11 | (byte & 0x01 ? '1' : '0') |
formulas | 0:a549a6b9b62e | 12 | |
formulas | 0:a549a6b9b62e | 13 | const uint8_t StartXPos=200; |
formulas | 0:a549a6b9b62e | 14 | const uint8_t StartYPos=20; |
formulas | 0:a549a6b9b62e | 15 | |
formulas | 0:a549a6b9b62e | 16 | |
formulas | 0:a549a6b9b62e | 17 | GEAR Gear1={80,120,GearBitmap1}; |
formulas | 0:a549a6b9b62e | 18 | /* GEAR Gear2 {0,0,GearBitmap2}; |
formulas | 0:a549a6b9b62e | 19 | GEAR Gear3 {0,0,GearBitmap3}; |
formulas | 0:a549a6b9b62e | 20 | GEAR Gear4 {0,0,GearBitmap4}; |
formulas | 0:a549a6b9b62e | 21 | GEAR Gear5 {0,0,GearBitmap5}; |
formulas | 0:a549a6b9b62e | 22 | GEAR Gear6 {0,0,GearBitmap6}; |
formulas | 0:a549a6b9b62e | 23 | */ |
formulas | 0:a549a6b9b62e | 24 | |
formulas | 0:a549a6b9b62e | 25 | |
formulas | 0:a549a6b9b62e | 26 | void PrintGear(GEAR Gear){ |
formulas | 0:a549a6b9b62e | 27 | uint8_t width=Gear.width; |
formulas | 0:a549a6b9b62e | 28 | uint8_t height=Gear.height; |
formulas | 0:a549a6b9b62e | 29 | uint8_t horpos,vertpos; |
formulas | 0:a549a6b9b62e | 30 | uint8_t bitloc; |
formulas | 0:a549a6b9b62e | 31 | char pos[8]; |
formulas | 0:a549a6b9b62e | 32 | for(vertpos=0;vertpos<height;vertpos++){ |
formulas | 0:a549a6b9b62e | 33 | for(horpos=0;horpos<width/8;horpos++){ |
formulas | 0:a549a6b9b62e | 34 | sprintf(pos,BYTE_TO_BINARY_PATTERN,BYTE_TO_BINARY(Gear.GearBitmap[vertpos*(width/8)+horpos])); |
formulas | 0:a549a6b9b62e | 35 | for(bitloc=0;bitloc<8;bitloc++) { |
formulas | 0:a549a6b9b62e | 36 | if (pos[bitloc]=='1') { |
formulas | 0:a549a6b9b62e | 37 | DrawPixel(200+horpos*8+bitloc,20+vertpos,000000); |
formulas | 0:a549a6b9b62e | 38 | } |
formulas | 0:a549a6b9b62e | 39 | } |
formulas | 0:a549a6b9b62e | 40 | } |
formulas | 0:a549a6b9b62e | 41 | } |
formulas | 0:a549a6b9b62e | 42 | }; |