This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
|
||||
// The sketch operates by creating a copy of the screen block where
|
||||
// the needle will be drawn, the needle is then drawn on the screen.
|
||||
// When the needle moves, the original copy of the sreen area is
|
||||
// When the needle moves, the original copy of the screen area is
|
||||
// pushed to the screen to over-write the needle graphic. A copy
|
||||
// of the screen where the new position will be drawn is then made
|
||||
// before drawing the needle in the new postion. This technique
|
||||
// before drawing the needle in the new position. This technique
|
||||
// allows the needle to move over other screen graphics.
|
||||
|
||||
// The sketch calculates the size of the buffer memory required and
|
||||
@@ -44,7 +44,7 @@ TFT_eSprite spr = TFT_eSprite(&tft); // Sprite for meter reading
|
||||
uint16_t* tft_buffer;
|
||||
bool buffer_loaded = false;
|
||||
uint16_t spr_width = 0;
|
||||
|
||||
uint16_t bg_color =0;
|
||||
// =======================================================================================
|
||||
// This function will be called during decoding of the jpeg file
|
||||
// =======================================================================================
|
||||
@@ -82,14 +82,14 @@ void setup() {
|
||||
|
||||
// Load the font and create the Sprite for reporting the value
|
||||
spr.loadFont(AA_FONT_LARGE);
|
||||
spr_width = spr.textWidth("277");
|
||||
spr_width = spr.textWidth("777"); // 7 is widest numeral in this font
|
||||
spr.createSprite(spr_width, spr.fontHeight());
|
||||
uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre
|
||||
bg_color = tft.readPixel(120, 120); // Get colour from dial centre
|
||||
spr.fillSprite(bg_color);
|
||||
spr.setTextColor(TFT_WHITE, bg_color);
|
||||
spr.setTextColor(TFT_WHITE, bg_color, true);
|
||||
spr.setTextDatum(MC_DATUM);
|
||||
spr.setTextPadding(spr_width);
|
||||
spr.drawNumber(0, spr_width/2, 0);
|
||||
spr.drawNumber(0, spr_width/2, spr.fontHeight()/2);
|
||||
spr.pushSprite(DIAL_CENTRE_X - spr_width / 2, DIAL_CENTRE_Y - spr.fontHeight() / 2);
|
||||
|
||||
// Plot the label text
|
||||
@@ -195,7 +195,7 @@ void plotNeedle(int16_t angle, uint16_t ms_delay)
|
||||
buffer_loaded = true;
|
||||
}
|
||||
|
||||
// Draw the needle in the new postion, black in needle image is transparent
|
||||
// Draw the needle in the new position, black in needle image is transparent
|
||||
needle.pushRotated(old_angle, TFT_BLACK);
|
||||
|
||||
// Wait before next update
|
||||
@@ -203,7 +203,8 @@ void plotNeedle(int16_t angle, uint16_t ms_delay)
|
||||
}
|
||||
|
||||
// Update the number at the centre of the dial
|
||||
spr.drawNumber(old_angle+120, spr_width/2, 0);
|
||||
spr.setTextColor(TFT_WHITE, bg_color, true);
|
||||
spr.drawNumber(old_angle+120, spr_width/2, spr.fontHeight()/2);
|
||||
spr.pushSprite(120 - spr_width / 2, 120 - spr.fontHeight() / 2);
|
||||
|
||||
// Slow needle down slightly as it approaches the new position
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
Paste the byte array into a sketch tab and add two lines
|
||||
at the start with a unique font name:
|
||||
|
||||
#include <pgmspace.h>
|
||||
const uint8_t fontName[] PROGMEM = {
|
||||
const uint8_t fontName[] PROGMEM = {
|
||||
|
||||
At the end add:
|
||||
|
||||
@@ -17,7 +16,6 @@
|
||||
#include "NotoSansBold36.h"
|
||||
*/
|
||||
|
||||
#include <pgmspace.h>
|
||||
// Digits 0-9 and .
|
||||
const uint8_t NotoSansBold36[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
Paste the byte array into a sketch tab "jpeg_name" and add
|
||||
two lines at the start with a unique array name:
|
||||
|
||||
#include <pgmspace.h>
|
||||
const uint8_t jpeg_name[] PROGMEM = {
|
||||
const uint8_t jpeg_name[] PROGMEM = {
|
||||
|
||||
At the end add:
|
||||
|
||||
@@ -17,7 +16,6 @@
|
||||
#include "jpeg_name.h"
|
||||
*/
|
||||
|
||||
#include <pgmspace.h>
|
||||
const uint8_t dial[] PROGMEM = {
|
||||
0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60,
|
||||
0x00, 0x60, 0x00, 0x00, 0xFF, 0xE1, 0x00, 0x5A, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4D, 0x4D,
|
||||
|
||||
Reference in New Issue
Block a user