Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Screen.h
00001 #ifndef SCREEN_H 00002 #define SCREEN_H 00003 00004 #include "MicroBit.h" 00005 #include "Sprite.h" 00006 00007 class Screen{ 00008 private: 00009 MicroBit *m_ubit; 00010 uint8_t buf[5][5]; 00011 public: 00012 Screen(MicroBit *ubit){ 00013 m_ubit = ubit; 00014 clearBuffer(); 00015 } 00016 void clearBuffer(){ 00017 for(int row = 0; row < 5; row++) 00018 for(int col = 0; col < 5; col++) 00019 buf[row][col] = 0; 00020 } 00021 00022 void draw(Sprite sprite){ 00023 buf[sprite.getX()][sprite.getY()] = 255; 00024 } 00025 void refresh(){ 00026 m_ubit->display.clear(); 00027 for(int row = 0; row < 5; row++){ 00028 for(int col = 0; col < 5; col++){ 00029 m_ubit->display.image.setPixelValue(row, col, buf[row][col]); 00030 } 00031 } 00032 clearBuffer(); 00033 } 00034 }; 00035 00036 #endif
Generated on Sun Aug 7 2022 05:10:42 by
1.7.2