Yes indeed, that's the very code I'm using at the moment. The problem is the people over at the Arduino Forum insist that the code is "not allowed" and bad C/C++ coding because the icon arrays are uint8_t and the DrawIcon function uses uint16_t. Here is a link to the discussions this issue appears towards the end of the discussion from post 20/38. Also it is very difficult for me to understand eactly how the DrawIcon function works, even though it most certainly does work. I have tried changing the uint16_t references in the function to uint8_t and the arrays to uint16_t but all I get with both changes is a black square instead of an icon.
Steve1
@Steve1
Posts made by Steve1
-
RE: Drawing an icon on the M5Paper from an array
-
Drawing an icon on the M5Paper from an array
On the M5Paper how can I draw an icon using a function with drawPixel() from an array of the form;
static const uint8_t SUNRISE64x64[8192] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff........}; -
RE: MPaper: How to read touch (or fingerUp) just one time.
Thanks for your patience ;-)
-
RE: MPaper: How to read touch (or fingerUp) just one time.
Well, yes it does. But why does the readFinger() have to be reaad three times?
for(int i=0;i<2; i++){
tp_finger_t FingerItem = M5.TP.readFinger(i); -
MPaper: How to read touch (or fingerUp) just one time.
I am programming my M5Paper with the Arduino IDE 2.2.1. I have tried everything I can think of to get just a single pair of x,y cordinates from a single touch on the M5Paper. I have tried comparing new coordinates with old and so on, but I haven't been able get just a single pair of coordinates and then wait for the net touch. Could someone show me how to achieve this?
-
M5Paper icon displaying as 2 small icons.
I am using an M5Paper and I have created a static const int8_t array using this website.
I then use the command
"DrawIcon(100, 780, (uint16_t *)Arrow_circle_down, 64, 64, true);"
together with the same drawIcon command for my other icons which are in an icon.h file I downloaded from the internet. All of the other icons display correctly but the icon I created displays as two small icons at the top and part of an unconnected icon at the bottom of the 64x64 square.
My working icon arrays look like this:
static const uint8_t SUNRISE64x64[8192] = {
0xff, 0xff, 0xff,........};My created icon array array looks like this;
// array size is 4096
static const int8_t Arrow_circle_down[] = {
0xff, 0xff, 0xff,........};I tried putting the array size 4096 in the square brackets but that made no difference.
The function drawIcon is:
void DrawIcon(int x, int y, const uint16_t icon, int dx /= 64/, int dy /= 64/, bool highContrast /= false/) {
for (int yi = 0; yi < dy; yi++) {
for (int xi = 0; xi < dx; xi++) {
uint16_t pixel = icon[yi * dx + xi];
if (highContrast) {
if (15 - (pixel / 4096) > 0) canvas.drawPixel(x + xi, y + yi, M5EPD_Canvas::G15);
} else {
canvas.drawPixel(x + xi, y + yi, 15 - (pixel / 4096));
}
}
}
}*Why is the created icon not displaying correctly?
-
M5Paper online PNG icons problem(s)
I have writen a sketch which gets JSON data from Open Weather Maps and displays it on my M5Paper device. I have included an icon for the weather which is obtained from https://openweathermap.org/img/wn/10d@2x.png with 10d replaced by the icon id for present weather conditions.
My first issue is that it takes literally minutes for the icon to actually appear, a long time after the other info has been displayed. Is this usual?
My second issue, possibly related to the first, is that when the M5Paper isn't connected to an external usb power source the icon simply never appears at all. All other data appears and is refreshed after a shutdown interval, but the icon never appears at all. What could be the cause?
-
RE: Cannot canvas.drawString() onto canvas. (M5PaperTouchArea)
I am just starting out with the M5Paper and a lot of things are taking some getting use to. I thought about deleting this thread when I found out how easy the solution was but then I thought that maybe this will help someone else. So here is the solution:
You have to declare a font for use in the canvasOP. So adding his line after creating canvasOP fixes the problem:
canvasOP.setFreeFont(&FreeSerif24pt7b); -
Cannot canvas.drawString() onto canvas. (M5PaperTouchArea)
I have made a small modification to RAWSEQ'sexcellent M5PaperTouchArea project.
I am trying to use the spare white area as an output canvas. I can place the CanvasOP (output canvas) correctly and I can check it is really there by filling it in different shades and moving it around. but I cannot write into it. Any canvasOP.drawString() commands seem to be ignored. I have tried changing the text color, size and position but I cannot seem to get text to show up on the pushed canvasOP.
#include <M5EPD.h> #include "M5PaperTouchArea.h" #include "MPlusFontsSubset.h" // M5EPD Canvas M5EPD_Canvas canvas(&M5.EPD); M5EPD_Canvas canvasOP(&M5.EPD); // Module (Grid & TouchArea) M5PaperTouchAreas _m5pta; // Module (Grid Only) GridUtil _gu; void setup() { // Display Setup M5.begin(); M5.EPD.SetRotation(90); M5.TP.SetRotation(90); M5.EPD.Clear(true); canvas.loadFont(MPlusFontsSubset, sizeof(MPlusFontsSubset)); canvas.createCanvas(540, 960); canvas.createRender(48, 256); canvas.fillRect(0, 0, 540, 960, 10); _m5pta.current_canvas = &canvas; _m5pta.getGutil()->setVertical(true); _gu.setVertical(true); // Event Setting _m5pta.e_touch.func = bTouch; _m5pta.e_release.func = bRelease; // Change Default Setting _m5pta.default_font_size = 48; _m5pta.default_radius = 15; _m5pta.default_font_linepos = 6; _m5pta.default_bc = { 13, 0, 0 }; // Touch Area Test _m5pta.add_grid(1, 1, 1, 1, "B1", "b1"); _m5pta.add_grid(2, 1, 1, 1, "B2", "b2"); _m5pta.add_grid(3, 1, 1, 1, "B3", "b3"); _m5pta.add_grid(4, 1, 1, 1, "B4", "b4"); _m5pta.add_grid(5, 1, 1, 1, "B5", "b5"); _m5pta.add_grid(1, 2, 3, 1, "B6", "b6"); _m5pta.add_grid(4, 2, 2, 1, "B7", "b7"); _m5pta.add_grid(1, 3, 2, 1, "B8", "b8"); _m5pta.add_grid(3, 3, 3, 1, "B9", "b9"); _m5pta.add_grid(1, 4, 5, 1, "B10 Steve", "Steve"); _m5pta.add_grid(1, 5, 2, 1, "B11", "b11"); //_m5pta.add_grid(3, 5, 3, 2, "B16", "b16");//added by steve _m5pta.add_grid(1, 6, 2, 2, "B12", "b12"); _m5pta.add_grid(3, 7, 3, 3, "B13", "b13"); _m5pta.add_grid(1, 8, 2, 1, "B14", "b14"); _m5pta.add_grid(1, 9, 2, 1, "B15", "b15"); _m5pta.draw(); // Grid Draw Test // GURect g = _gu.convert(3, 5, 3, 2); // canvas.setTextColor(10); // canvas.fillRect(g.x, g.y, g.w, g.h, 0); canvas.pushCanvas(0, 0, UPDATE_MODE_GC16); /* Serial.print(g.x); Serial.print("..."); Serial.print(g.y); Serial.print("..."); Serial.print(g.w); Serial.print("..."); Serial.print(g.h);*/ //230...440...290...180 g.cordinates canvasOP.createCanvas(290, 180); //canvasOP.fillCanvas(5); canvasOP.setTextSize(4); canvasOP.setTextColor(15); canvasOP.drawString("Hello", 20, 100); canvasOP.pushCanvas(230, 440, UPDATE_MODE_GC16); } // Touch Event void bTouch(M5PTAEventContext& ct) { Serial.println("T:" + ct.code); } // Release Event void bRelease(M5PTAEventContext& ct) { Serial.println("R:" + ct.code); } void loop() { _m5pta.loop(); }
-
Cannot compile M5Paper Weather sketch
I have downloaded this sketch along with all of the XX.h files and installed them in my Arduino directory, as I have prviously done with other GIT sketches. https://github.com/Bastelschlumpf/M5PaperWeather/tree/master/weather Unfortunately I cannot get this sketch to compile, it complains that in "..../Time.h MyData was not declared in this scope"
I have noticed that in Time.h there is the line 22 "#pragma once" which is not followed by any local XX.h files as it is in the other local libraries and .h files. I am nor familiar with" #pragma once" and am wondering if another library is supposed to declare MyData. MyData is declared as a class in Data.h.