ESP32 - PxMatrix Library - Making A Class
Posted: Tue Sep 22, 2020 6:13 pm
This is MyMatrix.h
Got 2 errors when i tried to make a class and putting this code inside it!
Line that is triggering
Code: Select all
//=================================================================================================================== //
// INCLUDES
//=================================================================================================================== //
#ifndef MYMATRIX_H
#define MYMATRIX_H
#include "PxMatrix.h"
#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 16
#define matrix_width 32
#define matrix_height 32
PxMATRIX display(matrix_width,matrix_height,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
unsigned long pixelArt[1024] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x1EC9, // 0x0010 (16) pixels
0x16C9, 0x06C7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0020 (32) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x4F0E, 0xAF77, 0xEFBD, 0xF7BE, // 0x0030 (48) pixels
0xF7BE, 0xE7BD, 0xAF77, 0x46ED, 0x06A7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0040 (64) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x16C8, 0xAF77, 0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, // 0x0050 (80) pixels
0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xAF77, 0x0EC8, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0060 (96) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x16C8, 0xCF7A, 0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, // 0x0070 (112) pixels
0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xC779, 0x0EC8, 0x06A7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0080 (128) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0xA756, 0xF79E, 0xF79E, 0xF79E, 0xF79E, 0xF7BE, 0xF7BE, // 0x0090 (144) pixels
0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xF7BE, 0xF79E, 0x9F55, 0x06C7, 0x06A7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00A0 (160) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x36EC, 0xEF7D, 0xF79D, 0xF79D, 0xF79D, 0xF79D, 0xF79E, 0xF79E, // 0x00B0 (176) pixels
0xF79E, 0xF79E, 0xF79E, 0xF79E, 0xF79E, 0xF79E, 0xF79D, 0x2EEB, 0x06C7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00C0 (192) pixels
0x0000, 0x0000, 0x0000, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x8F14, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, // 0x00D0 (208) pixels
0xEF7D, 0xEF9D, 0xF79D, 0xF79D, 0xEF9D, 0xEF7D, 0xEF7D, 0x8733, 0x06C7, 0x06C7, 0x06A7, 0x06A7, 0x06A7, 0x0000, 0x0000, 0x0000, // 0x00E0 (224) pixels
0x0000, 0x0000, 0xB717, 0x26CA, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0xBF38, 0xEF5D, 0xEF5D, 0xEF5D, 0xEF5D, 0xEF7D, 0xEF7D, 0xEF7D, // 0x00F0 (240) pixels
0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xEF7D, 0xB738, 0x06C7, 0x06C7, 0x06C7, 0x06A7, 0x2EAA, 0x9E74, 0x0000, 0x0000, // 0x0100 (256) pixels
0x0000, 0x0000, 0xE71C, 0x5EEF, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0xCF3A, 0xE73C, 0xE73C, 0xE75C, 0xEF5C, 0xEF5C, 0xEF5C, 0xEF5D, // 0x0110 (272) pixels
0xEF5D, 0xEF5D, 0xEF5D, 0xEF5D, 0xEF5D, 0xEF5D, 0xEF5C, 0xC739, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x66F0, 0xD69A, 0x0000, 0x0000, // 0x0120 (288) pixels
0x0000, 0xD6BA, 0xE71B, 0x86F3, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0xBF18, 0xE71C, 0xE71C, 0xE71C, 0xE73C, 0xE73C, 0xE73C, 0xE73C, // 0x0130 (304) pixels
0xE73C, 0xE73C, 0xE73C, 0xE73C, 0xE73C, 0xE73C, 0xE73C, 0xB717, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x86F3, 0xDEFB, 0xD6BA, 0x0000, // 0x0140 (320) pixels
0x0000, 0xD6BA, 0xDEFB, 0x96F4, 0x06A7, 0x06A7, 0x06A7, 0x06A7, 0x96F4, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, // 0x0150 (336) pixels
0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0xE71C, 0x86F3, 0x06C7, 0x06C7, 0x06C7, 0x06C7, 0x96F5, 0xDEFB, 0xD6BA, 0x0000, // 0x0160 (352) pixels
0xCE59, 0xD69A, 0xDEFB, 0x9ED5, 0x0686, 0x0686, 0x0687, 0x0687, 0x46AD, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, // 0x0170 (368) pixels
0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0x3EAC, 0x06A7, 0x06C7, 0x06C7, 0x06C7, 0x9EF5, 0xDEFB, 0xD6BA, 0xC638, // 0x0180 (384) pixels
0xCE58, 0xD69A, 0xDEFB, 0x8EB3, 0x0646, 0x0646, 0x0646, 0x0646, 0x0646, 0xAED6, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, // 0x0190 (400) pixels
0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xA6D6, 0x0687, 0x06A7, 0x06A7, 0x06C7, 0x06C7, 0x8EF3, 0xDEFB, 0xD69A, 0xC638, // 0x01A0 (416) pixels
0xC638, 0xD69A, 0xDEFB, 0x6E70, 0x05E6, 0x0606, 0x0606, 0x0626, 0x0606, 0x1E29, 0xCED9, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, // 0x01B0 (432) pixels
0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xDEFB, 0xC6D9, 0x1E69, 0x0666, 0x0687, 0x06A7, 0x06C7, 0x06C7, 0x6ED0, 0xDEDB, 0xD69A, 0xC638, // 0x01C0 (448) pixels
0xC638, 0xD69A, 0xDEDB, 0x460C, 0x05A6, 0x05A6, 0x05C6, 0x05C6, 0x05C6, 0x05E6, 0x2609, 0xBEB8, 0xDEDB, 0xDEDB, 0xDEDB, 0xDEDB, // 0x01D0 (464) pixels
0xDEDB, 0xDEDB, 0xDEDB, 0xDEDB, 0xB6B7, 0x2649, 0x0646, 0x0646, 0x0686, 0x0687, 0x06A7, 0x06A7, 0x3EAC, 0xDEDB, 0xD69A, 0xC638, // 0x01E0 (480) pixels
0xC638, 0xD699, 0xD6BA, 0x0D87, 0x0565, 0x0565, 0x0565, 0x0585, 0x0586, 0x05A6, 0x05A6, 0x0DA6, 0x662F, 0xBEB8, 0xDEDB, 0xDEDB, // 0x01F0 (496) pixels
0xDEDB, 0xDEDB, 0xBEB8, 0x664F, 0x05E6, 0x05E6, 0x0606, 0x0626, 0x0646, 0x0666, 0x0686, 0x0666, 0x0E47, 0xCEB9, 0xD699, 0xC638, // 0x0200 (512) pixels
0xC618, 0xCE79, 0x8E33, 0x0525, 0x0525, 0x0525, 0x0525, 0x0525, 0x0525, 0x0545, 0x0545, 0x0545, 0x0545, 0x0545, 0x1D68, 0x35AB, // 0x0210 (528) pixels
0x35AB, 0x1D88, 0x0565, 0x0565, 0x0585, 0x05A6, 0x05A6, 0x05C6, 0x05E6, 0x0606, 0x0626, 0x0606, 0x05C6, 0x8652, 0xCE79, 0xC618, // 0x0220 (544) pixels
0xC617, 0xCE79, 0x2508, 0x04E5, 0x04E5, 0x04E5, 0x04C5, 0x04C5, 0x04C5, 0x04C5, 0x04A4, 0x04A4, 0x0484, 0x04A4, 0x04A4, 0x04A4, // 0x0230 (560) pixels
0x04A4, 0x04A5, 0x04C5, 0x04E5, 0x04E5, 0x0505, 0x0545, 0x0545, 0x0585, 0x05A5, 0x05A5, 0x0585, 0x0545, 0x1D68, 0xC658, 0xC638, // 0x0240 (576) pixels
0xBDF7, 0x6D6F, 0x0464, 0x0464, 0x0444, 0x0444, 0x0444, 0x0444, 0x0424, 0x0404, 0x03E4, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C4, // 0x0250 (592) pixels
0x03E4, 0x03E4, 0x0404, 0x0404, 0x0424, 0x0464, 0x0484, 0x04A5, 0x04E5, 0x0505, 0x0505, 0x04E5, 0x04E5, 0x0505, 0x55AD, 0xC658, // 0x0260 (608) pixels
0x54AC, 0x03C4, 0x03C4, 0x03A3, 0x0363, 0x0363, 0x0363, 0x0363, 0x0363, 0x0323, 0x0303, 0x02E3, 0x02E3, 0x02E3, 0x0303, 0x0303, // 0x0270 (624) pixels
0x0323, 0x0343, 0x0343, 0x0363, 0x0383, 0x03A3, 0x03C3, 0x0404, 0x0424, 0x0444, 0x0464, 0x0484, 0x04A4, 0x04E5, 0x0545, 0x4DED, // 0x0280 (640) pixels
0x0323, 0x02E3, 0x02E3, 0x02E3, 0x02C2, 0x02A2, 0x02C2, 0x02A2, 0x02A2, 0x0282, 0x0282, 0x0262, 0x0263, 0x1AA4, 0x2AC4, 0x2AE5, // 0x0290 (656) pixels
0x2AE5, 0x2AE4, 0x1AC4, 0x02A3, 0x02C2, 0x02E3, 0x0303, 0x0343, 0x0363, 0x03A3, 0x03C4, 0x0404, 0x0464, 0x04C5, 0x0545, 0x05A6, // 0x02A0 (672) pixels
0x02A2, 0x0282, 0x0262, 0x0242, 0x0242, 0x0242, 0x0242, 0x0222, 0x0222, 0x1263, 0x4B06, 0x73A8, 0x8BEA, 0x940A, 0x940A, 0x940A, // 0x02B0 (688) pixels
0x940A, 0x940A, 0x8BEA, 0x8BC9, 0x7388, 0x4B06, 0x12A3, 0x02A2, 0x02E2, 0x0303, 0x0343, 0x03A3, 0x0424, 0x04C5, 0x0545, 0x0585, // 0x02C0 (704) pixels
0x0000, 0x0262, 0x0202, 0x0202, 0x0202, 0x0222, 0x0222, 0x1243, 0x6347, 0x942A, 0xA48B, 0xACAC, 0x7BAC, 0x9C4B, 0xB4ED, 0xB50D, // 0x02D0 (720) pixels
0xB50D, 0xB4ED, 0x9C2B, 0x7BAC, 0xA48B, 0x9C4B, 0x940A, 0x6368, 0x1283, 0x02A2, 0x0303, 0x0363, 0x03E4, 0x0484, 0x0505, 0x0000, // 0x02E0 (736) pixels
0x0000, 0x0000, 0x0202, 0x0202, 0x0202, 0x0202, 0x2284, 0x8C0A, 0xA48C, 0xB4ED, 0xC56E, 0xB4ED, 0xB554, 0x9C4C, 0xDE10, 0xDE10, // 0x02F0 (752) pixels
0xDE10, 0xDE10, 0x9C2C, 0xAD13, 0xB4ED, 0xC54E, 0xB4ED, 0xA48C, 0x8C0A, 0x22A4, 0x02A2, 0x0323, 0x03A3, 0x0424, 0x0000, 0x0000, // 0x0300 (768) pixels
0x0000, 0x0000, 0x0000, 0x0202, 0x0202, 0x0202, 0x73A9, 0xB4ED, 0xC56E, 0xDE10, 0xEE71, 0xC56E, 0x5227, 0x9C4B, 0xF6B2, 0xF6B2, // 0x0310 (784) pixels
0xF6B2, 0xF6B2, 0x8BEA, 0x4A06, 0xCDAF, 0xEE91, 0xDE30, 0xCD8F, 0xACAC, 0x6347, 0x0262, 0x02E3, 0x0363, 0x0000, 0x0000, 0x0000, // 0x0320 (800) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x09C2, 0x1A23, 0x8C4A, 0xCD8F, 0xD5F0, 0xE630, 0xEE91, 0xC56E, 0x2903, 0x9C2B, 0xF6D2, 0xF6D2, // 0x0330 (816) pixels
0xF6D2, 0xF6D2, 0x83A9, 0x2903, 0xCDAF, 0xF6B2, 0xEE91, 0xE630, 0xC56E, 0x7BA9, 0x1283, 0x02A3, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0340 (832) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB4EC, 0xCD8E, 0xD5CF, 0xDE10, 0xEE71, 0xD5CF, 0x0841, 0x9C4B, 0xF6D2, 0xF6D2, // 0x0350 (848) pixels
0xF6D2, 0xF6D2, 0x8BEA, 0x0840, 0xDE10, 0xF6B1, 0xEE71, 0xDE10, 0xBD4D, 0x9C4A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0360 (864) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB4EC, 0xBD4D, 0xCD8F, 0xD5EF, 0xE651, 0xEE91, 0x83A9, 0xDE30, 0xF6B2, 0xF6B2, // 0x0370 (880) pixels
0xF6B2, 0xF6B2, 0xDE10, 0x8BAA, 0xEEB1, 0xEE71, 0xE630, 0xD5CF, 0xB50C, 0x9C4A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0380 (896) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xACAC, 0xACAC, 0xBD2D, 0xCDAE, 0xDE10, 0xE671, 0xEE91, 0xEE91, 0xEE91, 0xEE91, // 0x0390 (912) pixels
0xEE91, 0xEE91, 0xEE91, 0xEE71, 0xE671, 0xDE30, 0xD5CF, 0xC54D, 0xA48B, 0x9C2A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x03A0 (928) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x940A, 0x940A, 0xACAC, 0xBD4D, 0xCDAF, 0xD5EF, 0xD5EF, 0xDE0F, 0xDE10, // 0x03B0 (944) pixels
0xDE10, 0xDE10, 0xD5EF, 0xD5CF, 0xCD8E, 0xC54D, 0xACCC, 0x9C2A, 0x940A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x03C0 (960) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7B68, 0x7B48, 0x7B89, 0x8BC9, 0x940A, 0x9C2A, 0x9C4B, 0x9C4B, // 0x03D0 (976) pixels
0x9C4B, 0x9C4B, 0x942A, 0x940A, 0x8BEA, 0x8BC9, 0x83A9, 0x83A9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x03E0 (992) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6B07, 0x6B07, 0x7307, 0x7307, 0x7328, 0x7328, // 0x03F0 (1008) pixels
0x7328, 0x7328, 0x7328, 0x7328, 0x7328, 0x7B48, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0400 (1024) pixels
};
//=================================================================================================================== //
// CLASS
//=================================================================================================================== //
class Matrix
{
public:
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
// This defines the 'on' time of the display is us. The larger this number,
// the brighter the display. If too large the ESP will crash
uint8_t display_draw_time=10; //10-50 is usually fine
void IRAM_ATTR display_updater()
{
// Increment the counter and set the time of ISR
portENTER_CRITICAL_ISR(&timerMux);
display.display(display_draw_time);
portEXIT_CRITICAL_ISR(&timerMux);
}
void display_update_enable(bool is_enable)
{
if (is_enable)
{
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &display_updater, true);
timerAlarmWrite(timer, 4000, true);
timerAlarmEnable(timer);
}
else
{
timerDetachInterrupt(timer);
timerAlarmDisable(timer);
}
}
void drawImage(int x, int y)
{
int imageHeight = 32;
int imageWidth = 32;
int counter = 0;
for (int yy = 0; yy < imageHeight; yy++)
{
for (int xx = 0; xx < imageWidth; xx++)
{
display.drawPixel(xx + x , yy + y, pixelArt[counter]);
counter++;
}
}
}
void begin()
{
display.begin(16);
display.clearDisplay();
display_update_enable(true);
}
void update()
{
drawImage(0, 0);
}
private:
};
Matrix matrix;
#endif
Code: Select all
argument of type "void (Matrix::*)()" is incompatible with parameter of type "void (*)()"
cannot convert 'void (Matrix::*)()' to 'void (*)()' for argument '2' to 'void timerAttachInterrupt(hw_timer_t*, void (*)(), bool)'
Code: Select all
timerAttachInterrupt(timer, &Matrix::display_updater, true);