Created
October 6, 2022 16:41
-
-
Save rafitc/a4a1a93792c2bc9a7b4eb8d372d6d1b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <TVout.h> | |
| #include <TVoutfonts/fontALL.h> | |
| #include <SoftwareSerial.h> | |
| TVout TV; | |
| unsigned char x,y; | |
| String st; | |
| const char *msg; | |
| unsigned int LengMsg; | |
| char finalMsg[100] = ""; | |
| SoftwareSerial mySerial(3, 2); | |
| void setup() { | |
| x=0; | |
| y=0; | |
| TV.begin(_NTSC,128,56); | |
| TV.select_font(font6x8); | |
| Serial.begin(9600); | |
| mySerial.begin(9600); | |
| Serial.println("Starting..."); | |
| delay(1000); | |
| mySerial.println("AT"); | |
| updateSerial(); | |
| mySerial.println("AT+CMGF=1"); | |
| updateSerial(); | |
| mySerial.println("AT+CNMI=1,2,0,0,0"); | |
| updateSerial(); | |
| } | |
| void loop(){ | |
| // pollSms(); | |
| displayMessage(); | |
| delay(500); | |
| displayMsgInTV(); | |
| } | |
| void displayMsgInTV() { | |
| TV.clear_screen(); | |
| x=0; | |
| y=0; | |
| for (char i = 32; i < 127; i++) { | |
| TV.print_char(x*6,y*8,i); | |
| x++; | |
| if (x >= TV.char_line()) { | |
| y++; | |
| x=0; | |
| } | |
| } | |
| TV.delay(1000); | |
| TV.clear_screen(); | |
| TV.println(finalMsg); | |
| TV.delay(1000); | |
| TV.clear_screen(); | |
| for(x=0;x<TV.hres();x++){ | |
| for(y=0;y<TV.vres();y++){ | |
| TV.set_pixel(x,y,1); | |
| } | |
| } | |
| } | |
| //------GSM Helper | |
| void displayMessage() | |
| { | |
| delay(500); | |
| String msg = ""; | |
| int start = 0, endPoint = 0; | |
| finalMsg[100] = ""; | |
| while (Serial.available()) | |
| { | |
| mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port | |
| // parseData(mySerial.readString());//Calls the parseData function to parse SMS | |
| } | |
| while (mySerial.available()) | |
| { | |
| msg = mySerial.readString();//Forward what Software Serial received to Serial Port | |
| } | |
| if (msg.length() > 1) { | |
| start = msg.indexOf('*') + 1; | |
| endPoint = msg.indexOf('#') - 1; | |
| int count = 0; | |
| if (start > 1 && endPoint > 1) { | |
| strcpy( finalMsg, ""); | |
| for (int i = start; i <= endPoint; i++) { | |
| finalMsg[count] = msg[i]; | |
| count++; | |
| } | |
| Serial.println("SMS Received: "); | |
| Serial.println(finalMsg); | |
| LengMsg = count; | |
| } | |
| else{ | |
| return false; | |
| } | |
| } | |
| } | |
| void updateSerial() | |
| { | |
| delay(500); | |
| while (Serial.available()) | |
| { | |
| mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port | |
| } | |
| while (mySerial.available()) | |
| { | |
| Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment