tim003 tim003
/
LV8_Grupa1_Tim003_Zadatak3
Tarik Demirović Aida Pločo
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "N5110.h" 00003 #include <string> 00004 00005 Serial pc(USBTX, USBRX); 00006 N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18); 00007 00008 DigitalOut enable (dp14); 00009 00010 int x = 0; 00011 int y = 0; 00012 00013 void ocitaj() 00014 { 00015 char buf[50]; 00016 buf[0] = pc.getc(); 00017 00018 if(buf[0] == '1') 00019 { 00020 y++; 00021 if(y > 5) y = 0; 00022 x = 0; 00023 } 00024 00025 else if(buf[0] == '2') 00026 { 00027 lcd.clear(); 00028 x = 0; 00029 y = 0; 00030 } 00031 00032 else if(buf[0] == '3') 00033 { 00034 x -= 5; 00035 if(x < 0 and y > 0){ 00036 x = 82; 00037 y--; 00038 } 00039 00040 lcd.printString(" ", x, y); 00041 } 00042 00043 else 00044 { 00045 lcd.printString(buf, x, y); 00046 x += 5; 00047 if(x > 83) 00048 { 00049 x = 0; 00050 y++; 00051 if( y > 5) y = 0; 00052 } 00053 } 00054 } 00055 00056 int main() { 00057 enable = 1; 00058 lcd.init(); 00059 lcd.setXYAddress(0, 0); 00060 pc.attach(&ocitaj); 00061 while(1) {} 00062 }
Generated on Sun Aug 7 2022 18:45:42 by 1.7.2