Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include \"mbed.h\"
- #include <iostream>
- #include <sstream>
- #include <bitset>
- #include <string>
- Serial pc( USBTX, USBRX );
- #include \"lcd_lib.h\"
- // two dimensional array with fixed size font
- extern uint8_t font8x8[ 256 ][ 8 ];
- class Bod
- {
- public:
- Bod( int x, int y, int barva ): x0( x ), y0( y ), rgb(barva) {};
- void kresli( int x = 0, int y = 0 ) { LCD_put_pixel( x0 + x, y0 + y, rgb ); }
- int x0, y0;
- int rgb;
- };
- class Usecka : public Bod{
- public:
- Usecka (int a, int b, int c, int d, int barva): Bod(a,c,barva), a( a ), b( b ),c(c),d(d){};
- void draw(){
- int dx,dy,p,x,y;
- dx=b-a;
- dy=d-c;
- x=a;
- y=c;
- p=2*dy-dx;
- while(x<b)
- {
- if(p>=0)
- {
- Bod::kresli(+x,+y);
- y=y+1;
- p=p+2*dy-2*dx;
- }
- else
- {
- Bod::kresli(x,y);
- p=p+2*dy;
- }
- x=x+1;
- }
- }
- int a,b,c,d,rgb;
- };
- class Znak {
- public:
- Znak(char c, int rgb, int offset):c ( c ),rgb(rgb),offset(offset){};
- void draw(){
- for(int x = 0; x < 8; x++){
- for(int y = 0; y <8; y++){
- if(font8x8[ int(c) ][ x ] & ( 1 << y )){
- LCD_put_pixel(y,x+offset,rgb);
- }
- else{
- LCD_put_pixel(y,x+offset,65535);
- }
- }
- }
- }
- char c;
- int rgb,offset;
- };
- int main()
- {
- LCD_init(); // LCD initialization
- LCD_clear(); // LCD clear screen
- pc.baud(115200);
- printf(\"ahoj\");
- int cervena = 0xF800;
- Znak cha(\'C\',cervena,0);
- cha.draw();
- Znak chb(\'A\',cervena,8);
- chb.draw();
- Znak chc(\'U\',cervena,16);
- chc.draw();
- Usecka cara(5,180,5,180,cervena);
- cara.draw();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement