valjda je to to

Dependencies:   BSP_DISCO_F469NIfdsf LCD_DISCO_F469NI mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Gear.cpp Source File

Gear.cpp

00001 #include "Gear.h"
00002 #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
00003 #define BYTE_TO_BINARY(byte)\
00004   (byte & 0x80 ? '1' : '0'),\
00005   (byte & 0x40 ? '1' : '0'),\
00006   (byte & 0x20 ? '1' : '0'),\
00007   (byte & 0x10 ? '1' : '0'),\
00008   (byte & 0x08 ? '1' : '0'),\
00009   (byte & 0x04 ? '1' : '0'),\
00010   (byte & 0x02 ? '1' : '0'),\
00011   (byte & 0x01 ? '1' : '0')
00012 
00013 const uint8_t StartXPos=200;
00014 const uint8_t StartYPos=20;
00015 
00016 
00017 GEAR Gear1={80,120,GearBitmap1};
00018 /* GEAR Gear2 {0,0,GearBitmap2};
00019 GEAR Gear3 {0,0,GearBitmap3};
00020 GEAR Gear4 {0,0,GearBitmap4};
00021 GEAR Gear5 {0,0,GearBitmap5};
00022 GEAR Gear6 {0,0,GearBitmap6};
00023 */
00024 
00025 
00026 void PrintGear(GEAR Gear){
00027     uint8_t width=Gear.width;
00028     uint8_t height=Gear.height;
00029     uint8_t horpos,vertpos;
00030     uint8_t bitloc;
00031     char pos[8];
00032     for(vertpos=0;vertpos<height;vertpos++){
00033         for(horpos=0;horpos<width/8;horpos++){
00034             sprintf(pos,BYTE_TO_BINARY_PATTERN,BYTE_TO_BINARY(Gear.GearBitmap[vertpos*(width/8)+horpos]));
00035             for(bitloc=0;bitloc<8;bitloc++) {
00036                 if (pos[bitloc]=='1') {
00037                     DrawPixel(200+horpos*8+bitloc,20+vertpos,000000);
00038                }
00039             }
00040         }
00041     }
00042 };