![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
sad radi
Dependencies: BSP_DISCO_F469NIfdsf LCD_DISCO_F469NI mbed
Fork of PrintGear by
Gear.cpp@1:b6c19373bd01, 2017-10-24 (annotated)
- Committer:
- formulas
- Date:
- Tue Oct 24 08:50:14 2017 +0000
- Revision:
- 1:b6c19373bd01
- Parent:
- 0:a549a6b9b62e
pokusaj2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
formulas | 0:a549a6b9b62e | 1 | #include "Gear.h" |
formulas | 1:b6c19373bd01 | 2 | #include "mbed.h" |
formulas | 0:a549a6b9b62e | 3 | #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" |
formulas | 0:a549a6b9b62e | 4 | #define BYTE_TO_BINARY(byte)\ |
formulas | 0:a549a6b9b62e | 5 | (byte & 0x80 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 6 | (byte & 0x40 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 7 | (byte & 0x20 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 8 | (byte & 0x10 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 9 | (byte & 0x08 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 10 | (byte & 0x04 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 11 | (byte & 0x02 ? '1' : '0'),\ |
formulas | 0:a549a6b9b62e | 12 | (byte & 0x01 ? '1' : '0') |
formulas | 0:a549a6b9b62e | 13 | |
formulas | 1:b6c19373bd01 | 14 | extern LCD_DISCO_F469NI lcd; |
formulas | 1:b6c19373bd01 | 15 | const uint32_t StartXPos=330; |
formulas | 1:b6c19373bd01 | 16 | const uint32_t StartYPos=70; |
formulas | 0:a549a6b9b62e | 17 | |
formulas | 0:a549a6b9b62e | 18 | |
formulas | 1:b6c19373bd01 | 19 | GEAR Gear1={160,328,GearBitmap1}; |
formulas | 0:a549a6b9b62e | 20 | /* GEAR Gear2 {0,0,GearBitmap2}; |
formulas | 0:a549a6b9b62e | 21 | GEAR Gear3 {0,0,GearBitmap3}; |
formulas | 0:a549a6b9b62e | 22 | GEAR Gear4 {0,0,GearBitmap4}; |
formulas | 0:a549a6b9b62e | 23 | GEAR Gear5 {0,0,GearBitmap5}; |
formulas | 0:a549a6b9b62e | 24 | GEAR Gear6 {0,0,GearBitmap6}; |
formulas | 0:a549a6b9b62e | 25 | */ |
formulas | 0:a549a6b9b62e | 26 | |
formulas | 0:a549a6b9b62e | 27 | |
formulas | 0:a549a6b9b62e | 28 | void PrintGear(GEAR Gear){ |
formulas | 1:b6c19373bd01 | 29 | uint32_t width=Gear.width; |
formulas | 1:b6c19373bd01 | 30 | uint32_t height=Gear.height; |
formulas | 1:b6c19373bd01 | 31 | uint32_t horpos,vertpos; |
formulas | 0:a549a6b9b62e | 32 | uint8_t bitloc; |
formulas | 1:b6c19373bd01 | 33 | char pos[50]; |
formulas | 1:b6c19373bd01 | 34 | //uint8_t dbg[50]; |
formulas | 0:a549a6b9b62e | 35 | for(vertpos=0;vertpos<height;vertpos++){ |
formulas | 0:a549a6b9b62e | 36 | for(horpos=0;horpos<width/8;horpos++){ |
formulas | 0:a549a6b9b62e | 37 | sprintf(pos,BYTE_TO_BINARY_PATTERN,BYTE_TO_BINARY(Gear.GearBitmap[vertpos*(width/8)+horpos])); |
formulas | 0:a549a6b9b62e | 38 | for(bitloc=0;bitloc<8;bitloc++) { |
formulas | 0:a549a6b9b62e | 39 | if (pos[bitloc]=='1') { |
formulas | 1:b6c19373bd01 | 40 | lcd.DrawPixel(StartXPos+horpos*8+bitloc,StartYPos+vertpos,0xFFF00000); |
formulas | 1:b6c19373bd01 | 41 | //wait_us(50); |
formulas | 1:b6c19373bd01 | 42 | //lcd.FillRect(StartXPos,StartYPos,StartXPos+horpos,StartYPos+vertpos); |
formulas | 0:a549a6b9b62e | 43 | } |
formulas | 0:a549a6b9b62e | 44 | } |
formulas | 0:a549a6b9b62e | 45 | } |
formulas | 0:a549a6b9b62e | 46 | } |
formulas | 1:b6c19373bd01 | 47 | |
formulas | 0:a549a6b9b62e | 48 | }; |