screen display for roommate tracker

Dependencies:   mbed-rtos mbed uLCD_4D_Picaso

Dependents:   RoommateTracker

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "uLCD_4D_Picaso.h"
00003 #include "Adafruit_FONA.h"
00004 #include "rtos.h"
00005 #include <string>
00006 #include <vector>
00007 
00008 #define FONA_RST p12
00009 #define FONA_TX p13
00010 #define FONA_RX p14
00011 #define FONA_RI p11
00012 
00013 using namespace std;
00014 Serial pc(USBTX, USBRX);
00015 Adafruit_FONA fona(FONA_TX, FONA_RX, FONA_RST, FONA_RI);
00016 
00017 Mutex mut;
00018 uLCD_4D_Picaso lcd(p28, p27, p30);
00019 
00020 vector <string> T_names;
00021 vector<string>::iterator name;
00022 
00023 
00024 
00025 char names[] = "Jesse\r\nGeorge\r\n";
00026 
00027 char phone[] = "7067664360\r\n4045189567\r\n";     
00028 
00029 int main() {
00030     //set up strings
00031     name = T_names.begin();
00032     name[1] = "Jesse";
00033     name[2] = "George";
00034     name[3] = "Cole";
00035     name[4] = "Brandon";
00036     
00037     lcd.setbaudWait(Picaso::BAUD_600000);
00038     lcd.touch_Set(0);
00039     lcd.txt_Opacity(Picaso::OPAQUE);
00040     
00041     //Set up header
00042     
00043     lcd.txt_MoveCursor(0, 6);
00044     lcd.txt_Attributes(Picaso::BOLD);
00045     lcd.txt_FGcolour(Picaso::RED);
00046     lcd.putStr("mbed Roomate Tracker");
00047     lcd.txt_MoveCursor(2, 0);
00048     lcd.txt_FGcolour(Picaso::CYAN);
00049     lcd.putStr("Who's home?");
00050     
00051     //print names
00052     
00053     lcd.txt_MoveCursor(4, 0);
00054     lcd.txt_Attributes(Picaso::UNDERLINED);
00055     lcd.putStr(names);
00056     
00057     //Set up touch boxes
00058     lcd.gfx_RectangleFilled(150, 250, 230, 310, Picaso::WHITE);
00059     lcd.gfx_RectangleFilled(0, 250, 80, 310, Picaso::WHITE);
00060     lcd.txt_MoveCursor(23, 3);
00061     lcd.txt_FGcolour(Picaso::WHITE);
00062     lcd.txt_Attributes(Picaso::UNDERLINED);
00063     lcd.putStr("HOME");
00064     lcd.txt_MoveCursor(23,22);
00065     lcd.putStr("AWAY");
00066     
00067     int status = 0;
00068     int x = 0;
00069     int y = 0;
00070     while (1) {
00071         status = lcd.touch_Get(0);
00072         if (status) {
00073             x = lcd.touch_Get(1);
00074             y = lcd.touch_Get(2);
00075                 if (status == 1 && x <= 80 && y >= 250) {
00076                     pc.printf("Text roomates home: I'm home\r\n");
00077                 } else if (status == 1 && x >= 150 && y >= 250) {
00078                     pc.printf("Text roommates away: I'm home\r\n");
00079                 }
00080         }
00081     }
00082 }