// To whom it may concern, // the huge matrix called "fontArray" is stored in the PROGMEM // the functions which call out to it work properly, and // adding it increased how much we could add to our program before it stopped working. // (more about progmem: ) http://www.arduino.cc/playground/Main/PROGMEM #include // Core graphics library #include // Hardware-specific library // #include // Font Driver by Sam and Adrian #include #include // The control pins for the LCD can be assigned to any digital or // analog pins...but we'll use the analog pins as this allows us to // double up the pins with the touch screen (see the TFT paint example). #define LCD_CS A3 // Chip Select goes to Analog 3 #define LCD_CD A2 // Command/Data goes to Analog 2 #define LCD_WR A1 // LCD Write goes to Analog 1 #define LCD_RD A0 // LCD Read goes to Analog 0 #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin // When using the BREAKOUT BOARD only, use these 8 data lines to the LCD: // For the Arduino Uno, Duemilanove, Diecimila, etc.: // D0 connects to digital pin 8 (Notice these are // D1 connects to digital pin 9 NOT in order!) // D2 connects to digital pin 2 // D3 connects to digital pin 3 // D4 connects to digital pin 4 // D5 connects to digital pin 5 // D6 connects to digital pin 6 // D7 connects to digital pin 7 // For the Arduino Mega, use digital pins 22 through 29 // (on the 2-row header at the end of the board). // Assign human-readable names to some common 16-bit color values: #define BLACK 0x0000 #define RED 0xF800 #define GREEN 0x07E0 // #define BLUE 0x001F // #define CYAN 0x07FF // #define MAGENTA 0xF81F // #define YELLOW 0xFFE0 // #define WHITE 0xFFFF Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // If using the shield, all control and data lines are fixed, and // a simpler declaration can optionally be used: // Adafruit_TFTLCD tft; #define wrap TRUE; // text wrapping ON PROGMEM int fontArray[][84]={ //0 {7 , 8 , 9 , 10, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 33, 34, 35, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 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 , 7 , 7 , 8 , 7 , 7 , 8 , 7 , 8 , 8 , 8 , 8 , 8 , 7 , 7 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 27, 28, 28, 28, 27, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //3 {16, 13, 11, 9 , 9 , 8 , 8 , 23, 8 , 24, 8 , 25, 26, 26, 26, 26, 26, 25, 25, 24, 23, 21, 12, 12, 11, 11, 12, 12, 23, 25, 26, 27, 27, 27, 28, 28, 27, 27, 27, 8 , 26, 7 , 25, 7 , 24, 7 , 20, 7 , 8 , 9 , 11, 14, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {2 , 3 , 4 , 5 , 6 , 7 , 8 , 8 , 9 , 9 , 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 43, 44, 45, 46, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {9 , 14, 18, 21, 22, 24, 7 , 9 , 5 , 8 , 3 , 8 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 8 , 8 , 9 , 17, 16, 16, 18, 19, 20, 10, 8 , 8 , 7 , 8 , 8 , 7 , 7 , 8 , 7 , 7 , 1 , 8 , 4 , 9 , 6 , 9 , 11, 12, 25, 22, 20, 16, 10, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //4 {4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {31, 29, 27, 26, 24, 22, 21, 19, 31, 17, 31, 16, 31, 14, 31, 12, 31, 11, 31, 9 , 31, 7 , 31, 5 , 31, 4 , 31, 3 , 31, 3 , 31, 2 , 2 , 2 , 2 , 3 , 3 , 3 , 31, 31, 31, 31, 31, 32, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {5 , 7 , 10, 11, 13, 15, 16, 10, 6 , 11, 6 , 10, 6 , 10, 6 , 11, 6 , 10, 6 , 10, 6 , 11, 6 , 11, 6 , 10, 6 , 9 , 6 , 8 , 6 , 43, 44, 45, 45, 44, 43, 43, 6 , 6 , 6 , 6 , 6 , 4 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //5 {10, 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 17, 9 , 9 , 9 , 9 , 10, 23, 25, 26, 27, 28, 28, 28, 28, 28, 28, 28, 27, 27, 26, 7 , 25, 7 , 24, 7 , 19, 7 , 7 , 8 , 10, 13, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 39, 40, 40, 41, 41, 42, 43, 44, 45, 46, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {22, 23, 23, 23, 23, 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 4 , 18, 20, 21, 23, 22, 10, 9 , 8 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 8 , 3 , 8 , 5 , 9 , 10, 13, 24, 23, 20, 17, 10, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //6 {6 , 7 , 8 , 9 , 10, 11, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 34, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {20, 15, 12, 10, 9 , 7 , 6 , 5 , 21, 35, 5 , 21, 38, 4 , 20, 40, 4 , 20, 40, 3 , 20, 41, 3 , 20, 41, 3 , 19, 42, 2 , 19, 42, 2 , 19, 42, 2 , 19, 41, 2 , 19, 41, 2 , 19, 41, 2 , 19, 40, 2 , 20, 39, 2 , 20, 38, 2 , 20, 34, 3 , 21, 3 , 21, 3 , 22, 4 , 23, 25, 27, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {13, 23, 28, 32, 34, 37, 39, 11, 6 , 11, 8 , 5 , 8 , 8 , 6 , 6 , 6 , 5 , 7 , 7 , 5 , 6 , 6 , 5 , 6 , 5 , 6 , 5 , 6 , 6 , 5 , 6 , 6 , 5 , 5 , 6 , 6 , 5 , 6 , 6 , 5 , 6 , 6 , 5 , 6 , 6 , 6 , 6 , 7 , 6 , 7 , 7 , 6 , 11, 11, 5 , 23, 6 , 22, 6 , 20, 5 , 18, 15, 10, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //7 {6 , 6 , 6 , 6 , 6 , 28, 27, 27, 26, 26, 25, 25, 24, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 13, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {28, 29, 29, 29, 29, 6 , 7 , 6 , 7 , 7 , 7 , 7 , 7 , 7 , 6 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 6 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 8 , 7 , 7 , 7 , 7 , 7 , 7 , 8 , 7 , 8 , 7 , 3 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, //8 {16, 13, 11, 10, 9 , 8 , 23, 8 , 25, 7 , 26, 7 , 27, 7 , 27, 7 , 27, 7 , 27, 7 , 27, 7 , 27, 7 , 26, 8 , 25, 8 , 24, 9 , 23, 10, 21, 11, 12, 14, 14, 12, 11, 9 , 21, 8 , 23, 8 , 25, 7 , 26, 6 , 27, 6 , 28, 6 , 28, 5 , 28, 5 , 29, 5 , 28, 5 , 28, 6 , 28, 6 , 27, 6 , 26, 7 , 23, 8 , 8 , 10, 11, 15}, {2 , 3 , 4 , 5 , 6 , 7 , 7 , 8 , 8 , 9 , 9 , 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 43, 44, 45, 46}, {9 , 15, 19, 21, 23, 10, 9 , 7 , 8 , 7 , 7 , 7 , 6 , 6 , 7 , 6 , 7 , 6 , 6 , 6 , 6 , 7 , 6 , 7 , 7 , 7 , 7 , 9 , 8 , 9 , 8 , 10, 9 , 18, 15, 12, 14, 17, 20, 9 , 11, 9 , 10, 7 , 8 , 7 , 8 , 7 , 7 , 7 , 7 , 6 , 7 , 7 , 7 , 7 , 6 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 8 , 8 , 10, 10, 24, 24, 20, 17, 10}, //9 {6 , 7 , 8 , 8 , 9 , 9 , 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 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 9 , 13, 17, 21, 25, 28, 27, 25, 22, 18, 13, 9 , 8 , 11, 15, 20, 23, 23, 23, 22, 19, 15, 12, 14, 18, 22, 25, 25, 25, 23, 20, 16, 12, 8 , 8 , 12, 17, 21, 23, 25, 25, 23, 19, 15, 12, 8 , 4 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } }; void setup(void) { Serial.begin(9600); Serial.println("TFT LCD test"); #ifdef USE_ADAFRUIT_SHIELD_PINOUT Serial.println("Using Adafruit 2.8\" TFT Arduino Shield Pinout"); #else Serial.println("Using Adafruit 2.8\" TFT Breakout Board Pinout"); #endif tft.reset(); uint16_t identifier = tft.readID(); if(identifier == 0x9325) { Serial.println(PSTR("Found ILI9325 LCD driver")); } else if(identifier == 0x9328) { Serial.println(PSTR("Found ILI9328 LCD driver")); } else if(identifier == 0x7575) { Serial.println(PSTR("Found HX8347G LCD driver")); } else { Serial.print(PSTR("Unknown LCD driver chip: ")); Serial.println(identifier, HEX); Serial.println(PSTR("If using the Adafruit 2.8\" TFT Arduino shield, the line:")); Serial.println(PSTR(" #define USE_ADAFRUIT_SHIELD_PINOUT")); Serial.println(PSTR("should appear in the library header (Adafruit_TFT.h).")); Serial.println(PSTR("If using the breakout board, it should NOT be #defined!")); Serial.println(PSTR("Also if using the breakout, double-check that all wiring")); Serial.println(PSTR("matches the tutorial.")); return; } tft.begin(identifier); tft.setRotation(3); tft.fillScreen(BLACK); // screen background is black Serial.begin(9600); } void loop(void){ boolean a=true; for (int k=0; k<50; k++){ a=(k%2==1); float aMillion = 1000000; drawArrow(GREEN, a); printWatts(aMillion * senseWattage()); delay(300); tft.fillScreen(BLACK); // screen background is black } } /// end of main loop float senseWattage(){ int voltageBits = analogRead(A0); // read the input on analog pin 0: float voltageVolts = voltageBits*0.00488759; // converts bits to volts float sensedVoltage = voltageVolts*8.5965; // Scalar determined by the voltage divider to pin A0 int currentValue = analogRead(A1); float sensedCurrent = currentValue * 0.00488759; // convert current sensor voltage output from bits to volts sensedCurrent = (sensedCurrent-2.5) * 10 + 0.3; // for -30 use 15.15+0.3 for -20 use 10.0+0.3 return sensedCurrent * sensedVoltage; } void drawArrow(int color, boolean left) { /// initialize all points as if it's drawing a right arrow, then ::: int rectX= -38; int triTopBot= 30; int triPoint= 120; if (left) // ::: switch them if it's facing left. { rectX*= -1; //rectX= 38; triTopBot*= -1; //triTopBot= -30; triPoint*= -1; //triPoint= -120; } tft.fillRect(93+rectX, 41, 135, 110, color); //x, y, w, h, color **Origin is bottom left tft.fillTriangle(161+triTopBot, 186, 160+triTopBot, 6, 160+triPoint, 96, color); //3 pairs of vertices, color } // print char input: signed char number, int x_coord, int y_coord, int color) ; // XY are top left of char print spot // print char output: unsigned int - increment the cursor by this many pixels unsigned int printChar(signed char input, unsigned int x, unsigned int y, unsigned int color ){ // 0 1 2 3 4 5 6 7 8 9 . W // 0 3 6 9 12 15 18 21 24 27 30 33 // V V H H V H V H H V H V unsigned int charWidth=42; if (input==-16){ // input is a space. return 20;} // draw nothing, return 20 so the calling function knows to increment its cursor else if(input<0){ //decimal point. starts at 30, is H input=10; // make the next bit of lookup table work in my favor. charWidth=20;} else if(input>9){// W. starts at 33, is drawn with H input=11; // make the next bit of lookup table work in my favor. charWidth=56; } byte row_start=input*3; // holds the offset for the font vector in pgmem byte dir_lookup[] = {1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1}; // a lookup table for the draw-directions byte draw_dir=dir_lookup[input]; // indicates the draw function to draw horizontal (0) or vertical (1) for each character // now draw_dir is either 0 (indicating horizontal) or 1 (indicating vertical) // and row_start is the row in the pgmem table at which the current piece of the font vector is stored. int i=0; // conumn pointer for fetching vector information from pgmem. while (pgm_read_byte(&fontArray[row_start][i])>0){ // loop until the zero point is found. if (draw_dir==1){ tft.drawFastVLine( x+pgm_read_byte(&fontArray[row_start ][i]), y+pgm_read_byte(&fontArray[row_start+1][i]), 0+pgm_read_byte(&fontArray[row_start+2][i]), color);} else { tft.drawFastHLine( x+pgm_read_byte(&fontArray[row_start ][i]), y+pgm_read_byte(&fontArray[row_start+1][i]), 0+pgm_read_byte(&fontArray[row_start+2][i]), color);} i++; // increment the column pointer i } return charWidth; } // Function to print a calculated wattage value on the screen // Pass the value in in microwatts. MICROWATTS // the integer 'digits' is how many digits to print. Decimal point is not included. void printWatts(signed long wattage){ // that long has the unit of MICROWATTS. Don't you forget it. // now the input wattage (unit: uW) is to be converted into a string // the conversion from long-int to string is implicit String wattage_left = String(wattage/1000000); // get numbers from the left of the dp String wattage_right = String(wattage%1000000); // get the stuff after the decimal point, seperately while (wattage_right.length()<6){ wattage_right = "0"+wattage_right; // fix the problem of the dropped zero after the dp } String dp = String("."); // Decimal point string to be used in concatenation String wattage_string = wattage_left + dp + wattage_right; // concatentate strings, add the decimal point String units = String(" W"); wattage_string = wattage_string.substring(0,5) + units; if (wattage==0){wattage_string=String("0.000 W");} unsigned int myCursor[]={10, 187}; // holds the location to print to for (int i=0; i<7; i++){ myCursor[0] = myCursor[0] + printChar((signed char)byte(wattage_string.charAt(i))-48, myCursor[0], myCursor[1], GREEN); } } /* unsigned long testText() { tft.fillScreen(BLACK); unsigned long start = micros(); tft.setCursor(0, 0); tft.setTextColor(WHITE); tft.setTextSize(1); tft.println("Hello World!"); tft.setTextColor(YELLOW); tft.setTextSize(2); tft.println(1234.56); tft.setTextColor(RED); tft.setTextSize(3); tft.println(0xDEADBEEF, HEX); tft.println(); tft.setTextColor(GREEN); tft.setTextSize(5); tft.println("Groop"); tft.setTextSize(2); tft.println("I implore thee,"); tft.setTextSize(1); tft.println("my foonting turlingdromes."); tft.println("And hooptiously drangle me"); tft.println("with crinkly bindlewurdles,"); tft.println("Or I will rend thee"); tft.println("in the gobberwarts"); tft.println("with my blurglecruncheon,"); tft.println("see if I don't!"); return micros() - start; } */