Skip to content

Commit 6025e7a

Browse files
author
dave
committed
recompile examples on V1.7
1 parent 87f92f5 commit 6025e7a

19 files changed

+166
-223
lines changed

examples/nokia5110/nokia5110_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ void setupMenu() {
7474
gfx.setRotation(0);
7575
renderer.setGraphicsDevice(&gfx, &gfxConfig);
7676
switches.initialise(internalDigitalIo(), true);
77-
menuMgr.initForEncoder(&renderer, &menuHall, 2, 3, A3);
77+
menuMgr.initForEncoder(&renderer, &menuHall, 2, 6, A3);
7878
remoteServer.begin(&server, &applicationInfo);
7979
}

examples/nokia5110/securitySystem.emf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lastEdited": {
3-
"seconds": 1603018923,
3+
"seconds": 1604328319,
44
"nanos": 0
55
},
66
"codeOptions": {
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"name": "ENCODER_PIN_B",
39-
"latestValue": "3",
39+
"latestValue": "6",
4040
"subsystem": "INPUT"
4141
},
4242
{

examples/nokia5110/tcMenuAdaFruitGfx.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,53 @@ void AdaGfxDialog::drawButton(Adafruit_GFX* gfx, AdaColorGfxMenuConfig* config,
402402
gfx->print(title);
403403
}
404404

405+
406+
/** A couple of helper functions that we'll submit for inclusion once a bit more testing is done */
407+
408+
/**************************************************************************/
409+
/*!
410+
@brief Draw a RAM-resident 1-bit image at the specified (x,y) position,
411+
from image data that may be wider or taller than the desired width and height.
412+
Imagine a cookie dough rolled out, where you can cut a rectangle out of it.
413+
It uses the specified foreground (for set bits) and background (unset bits) colors.
414+
This is particularly useful for GFXCanvas1 operations, where you can allocate the
415+
largest canvas needed and then use it for all drawing operations.
416+
417+
@param x Top left corner x coordinate
418+
@param y Top left corner y coordinate
419+
@param bitmap byte array with monochrome bitmap
420+
@param w width of the portion you want to draw
421+
@param h Height of the portion you want to draw
422+
@param totalWidth actual width of the bitmap
423+
@param xStart X position of the image in the data
424+
@param yStart Y position of the image in the data
425+
@param color 16-bit 5-6-5 Color to draw pixels with
426+
@param bg 16-bit 5-6-5 Color to draw background with
427+
*/
428+
/**************************************************************************/
429+
void drawCookieCutBitmap(Adafruit_GFX* gfx, int16_t x, int16_t y, const uint8_t *bitmap, int16_t w,
430+
int16_t h, int16_t totalWidth, int16_t xStart, int16_t yStart,
431+
uint16_t fgColor, uint16_t bgColor) {
432+
433+
// total width here is different to the width we are drawing, imagine rolling out a long
434+
// line of dough and cutting cookies from it. The cookie is the part of the image we want
435+
uint16_t byteWidth = (totalWidth + 7) / 8; // Bitmap scanline pad = whole byte
436+
uint16_t yEnd = h + yStart;
437+
uint16_t xEnd = w + xStart;
438+
uint8_t byte;
439+
440+
gfx->startWrite();
441+
442+
for (uint16_t j = yStart; j < yEnd; j++, y++) {
443+
byte = bitmap[size_t(((j * byteWidth) + xStart) / 8)];
444+
for (uint16_t i = xStart; i < xEnd; i++) {
445+
if (i & 7U)
446+
byte <<= 1U;
447+
else
448+
byte = bitmap[size_t((j * byteWidth) + i / 8)];
449+
gfx->writePixel(x + (i - xStart), y, (byte & 0x80U) ? fgColor : bgColor);
450+
}
451+
}
452+
453+
gfx->endWrite();
454+
}

examples/nokia5110/tcMenuAdaFruitGfx.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ extern const ConnectorLocalInfo applicationInfo;
5050
*/
5151
typedef struct ColorGfxMenuConfig<const GFXfont*> AdaColorGfxMenuConfig;
5252

53+
void drawCookieCutBitmap(Adafruit_GFX* gfx, int16_t x, int16_t y, const uint8_t *bitmap, int16_t w,
54+
int16_t h, int16_t totalWidth, int16_t xStart, int16_t yStart,
55+
uint16_t fgColor, uint16_t bgColor);
56+
5357
/**
5458
* A basic renderer that can use the AdaFruit_GFX library to render information onto a suitable
5559
* display. It is your responsibility to fully initialise and prepare the display before passing
@@ -99,6 +103,16 @@ class AdaGfxDialog : public BaseDialog {
99103
void drawButton(Adafruit_GFX* gfx, AdaColorGfxMenuConfig* config, const char* title, uint8_t num, bool active);
100104
};
101105

106+
/**
107+
* Provides the extents of the text as a Coord which is easier to work with.
108+
* @param graphics the graphics object as a pointer
109+
* @param text the text to measure
110+
* @param x starting location X
111+
* @param y starting location Y
112+
* @return the coord object containing width and height
113+
*/
114+
Coord textExtents(Adafruit_GFX* graphics, const char* text, int16_t x, int16_t y);
115+
102116
/**
103117
* The default graphics configuration for Ada GFX that needs no fonts and uses reasonable spacing options
104118
* for 100 - 150 dpi displays.

examples/remoteControlSerial/remoteControlSerial.emf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lastEdited": {
3-
"seconds": 1603019484,
3+
"seconds": 1604329022,
44
"nanos": 0
55
},
66
"codeOptions": {
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"name": "ENCODER_PIN_B",
39-
"latestValue": "3",
39+
"latestValue": "6",
4040
"subsystem": "INPUT"
4141
},
4242
{

examples/remoteControlSerial/remoteControlSerial_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ void setupMenu() {
5858
gfx.setRotation(0);
5959
renderer.setGraphicsDevice(&gfx, &gfxConfig);
6060
switches.initialise(internalDigitalIo(), true);
61-
menuMgr.initForEncoder(&renderer, &menuAnalogIn, 2, 3, A3);
61+
menuMgr.initForEncoder(&renderer, &menuAnalogIn, 2, 6, A3);
6262
remoteServer.begin(&Serial1, &applicationInfo);
6363
}

examples/remoteControlSerial/tcMenuAdaFruitGfx.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,53 @@ void AdaGfxDialog::drawButton(Adafruit_GFX* gfx, AdaColorGfxMenuConfig* config,
402402
gfx->print(title);
403403
}
404404

405+
406+
/** A couple of helper functions that we'll submit for inclusion once a bit more testing is done */
407+
408+
/**************************************************************************/
409+
/*!
410+
@brief Draw a RAM-resident 1-bit image at the specified (x,y) position,
411+
from image data that may be wider or taller than the desired width and height.
412+
Imagine a cookie dough rolled out, where you can cut a rectangle out of it.
413+
It uses the specified foreground (for set bits) and background (unset bits) colors.
414+
This is particularly useful for GFXCanvas1 operations, where you can allocate the
415+
largest canvas needed and then use it for all drawing operations.
416+
417+
@param x Top left corner x coordinate
418+
@param y Top left corner y coordinate
419+
@param bitmap byte array with monochrome bitmap
420+
@param w width of the portion you want to draw
421+
@param h Height of the portion you want to draw
422+
@param totalWidth actual width of the bitmap
423+
@param xStart X position of the image in the data
424+
@param yStart Y position of the image in the data
425+
@param color 16-bit 5-6-5 Color to draw pixels with
426+
@param bg 16-bit 5-6-5 Color to draw background with
427+
*/
428+
/**************************************************************************/
429+
void drawCookieCutBitmap(Adafruit_GFX* gfx, int16_t x, int16_t y, const uint8_t *bitmap, int16_t w,
430+
int16_t h, int16_t totalWidth, int16_t xStart, int16_t yStart,
431+
uint16_t fgColor, uint16_t bgColor) {
432+
433+
// total width here is different to the width we are drawing, imagine rolling out a long
434+
// line of dough and cutting cookies from it. The cookie is the part of the image we want
435+
uint16_t byteWidth = (totalWidth + 7) / 8; // Bitmap scanline pad = whole byte
436+
uint16_t yEnd = h + yStart;
437+
uint16_t xEnd = w + xStart;
438+
uint8_t byte;
439+
440+
gfx->startWrite();
441+
442+
for (uint16_t j = yStart; j < yEnd; j++, y++) {
443+
byte = bitmap[size_t(((j * byteWidth) + xStart) / 8)];
444+
for (uint16_t i = xStart; i < xEnd; i++) {
445+
if (i & 7U)
446+
byte <<= 1U;
447+
else
448+
byte = bitmap[size_t((j * byteWidth) + i / 8)];
449+
gfx->writePixel(x + (i - xStart), y, (byte & 0x80U) ? fgColor : bgColor);
450+
}
451+
}
452+
453+
gfx->endWrite();
454+
}

examples/remoteControlSerial/tcMenuAdaFruitGfx.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ extern const ConnectorLocalInfo applicationInfo;
5050
*/
5151
typedef struct ColorGfxMenuConfig<const GFXfont*> AdaColorGfxMenuConfig;
5252

53+
void drawCookieCutBitmap(Adafruit_GFX* gfx, int16_t x, int16_t y, const uint8_t *bitmap, int16_t w,
54+
int16_t h, int16_t totalWidth, int16_t xStart, int16_t yStart,
55+
uint16_t fgColor, uint16_t bgColor);
56+
5357
/**
5458
* A basic renderer that can use the AdaFruit_GFX library to render information onto a suitable
5559
* display. It is your responsibility to fully initialise and prepare the display before passing
@@ -99,6 +103,16 @@ class AdaGfxDialog : public BaseDialog {
99103
void drawButton(Adafruit_GFX* gfx, AdaColorGfxMenuConfig* config, const char* title, uint8_t num, bool active);
100104
};
101105

106+
/**
107+
* Provides the extents of the text as a Coord which is easier to work with.
108+
* @param graphics the graphics object as a pointer
109+
* @param text the text to measure
110+
* @param x starting location X
111+
* @param y starting location Y
112+
* @return the coord object containing width and height
113+
*/
114+
Coord textExtents(Adafruit_GFX* graphics, const char* text, int16_t x, int16_t y);
115+
102116
/**
103117
* The default graphics configuration for Ada GFX that needs no fonts and uses reasonable spacing options
104118
* for 100 - 150 dpi displays.

examples/simpleU8g2/simpleU8g2.emf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lastEdited": {
3-
"seconds": 1601471552,
3+
"seconds": 1604331729,
44
"nanos": 0
55
},
66
"codeOptions": {

examples/takeOverDisplay/takeOverDisplay.emf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lastEdited": {
3-
"seconds": 1599238176,
3+
"seconds": 1604329219,
44
"nanos": 0
55
},
66
"codeOptions": {
@@ -12,6 +12,7 @@
1212
"embeddedPlatform": "ARDUINO_AVR",
1313
"namingRecursive": true,
1414
"saveToSrc": false,
15+
"useCppMain": false,
1516
"lastProperties": [
1617
{
1718
"name": "PULLUP_LOGIC",

0 commit comments

Comments
 (0)