Hello, everyone! I am shalekberli. I can't find my problem issue Please find my issue and write an answer.
But my code is very long. That's why Arduino don't agree for I write my code. I write the a piece of the issue. Here is:
void onDraw(unsigned long currentTime) {
if(!isDisplayTime(currentTime)) // Do not re-draw at every tick
return;
if(displayMode == DISPLAY_MODE_START_UP) {
drawStartUp();
}
else if(displayMode == DISPLAY_MODE_CLOCK) {
if(isClicked == LOW) { // User input received
startEmergencyMode();
setPageChangeTime(0); // Change mode with no page-delay
setNextDisplayTime(currentTime, 0); // Do not wait next re-draw time
}
else {
drawClock();
if(isPageChangeTime(currentTime)) { // It's time to go into idle mode
startIdleMode();
setPageChangeTime(currentTime); // Set a short delay
}
setNextDisplayTime(currentTime, CLOCK_DISP_INTERVAL);
}
}
else if(displayMode == DISPLAY_MODE_EMERGENCY_MSG) {
if(findNextEmerMessage()) {
drawEmergency();
emgCurDisp++;
if(emgCurDisp >= EMG_COUNT_MAX) {
emgCurDisp = 0;
startMessageMode();
}
setNextDisplayTime(currentTime, EMERGENCY_DISP_INTERVAL);
}
// There's no message left to display. Go to normal message mode.
else {
startMessageMode();
//setPageChangeTime(0);
setNextDisplayTime(currentTime, 0); // with no re-draw interval
}
}
else if(displayMode == DISPLAY_MODE_NORMAL_MSG) {
if(findNextNormalMessage()) {
drawMessage();
msgCurDisp++;
if(msgCurDisp >= MSG_COUNT_MAX) {
msgCurDisp = 0;
startClockMode();
}
setNextDisplayTime(currentTime, MESSAGE_DISP_INTERVAL);
}
// There's no message left to display. Go to clock mode.
else {
startClockMode();
setPageChangeTime(currentTime);
setNextDisplayTime(currentTime, 0); // with no re-draw interval
}
}
else if(displayMode == DISPLAY_MODE_IDLE) {
if(isClicked == LOW) { // Wake up watch if there's an user input
startClockMode();
setPageChangeTime(currentTime);
setNextDisplayTime(currentTime, 0);
}
else {
drawIdleClock();
setNextDisplayTime(currentTime, IDLE_DISP_INTERVAL);
}
}
else {
startClockMode(); // This means there's an error
}
Sketch uses 20850 bytes (67%) of program storage space. Maximum is 30720 bytes.
Global variables use 836 bytes (40%) of dynamic memory, leaving 1212 bytes for local variables. Maximum is 2048 bytes.
I had to guess what you'd put in bitmap.h and fake some variables...
Nope, not missing anything. Renamed as cpp and added a valid ino module to the sketch.
Compiling...
Arduino: 1.8.12 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"
bitmap.cpp:172:18: error: 'HIGH' was not declared in this scope
bool isClicked = HIGH;
^~~~
sketch\bitmap.cpp: In function 'void setup()':
bitmap.cpp:177:3: error: 'Serial' was not declared in this scope
Serial.begin(9600); // WARNING: Do not enable this if there is not enough memory
^~~~~~
sketch\bitmap.cpp:177:3: note: suggested alternative: 'BTSerial'
Serial.begin(9600); // WARNING: Do not enable this if there is not enough memory
^~~~~~
BTSerial
bitmap.cpp:184:3: error: 'init_emg_array' was not declared in this scope
init_emg_array();
^~~~~~~~~~~~~~
...FAR MORE ERRORS THAN I CAN POST HERE IN THE FORUM LIMIT...
^~~~~~~~~~~~~~
bitmap.cpp:584:15: error: 'HIGH' was not declared in this scope
isClicked = HIGH;
^~~~
sketch\bitmap.cpp: In function 'bool isDisplayTime(long unsigned int)':
bitmap.cpp:595:20: error: 'LOW' was not declared in this scope
if (isClicked == LOW) {
^~~
bitmap.cpp:596:5: error: 'delay' was not declared in this scope
delay(500);
^~~~~
sketch\bitmap.cpp: In function 'void drawStartUp()':
bitmap.cpp:747:5: error: 'u8g_prepare' was not declared in this scope
u8g_prepare();
^~~~~~~~~~~
sketch\bitmap.cpp:747:5: note: suggested alternative: 'u8g_Delay'
u8g_prepare();
^~~~~~~~~~~
u8g_Delay
sketch\bitmap.cpp: In function 'void drawEmergency()':
bitmap.cpp:778:5: error: 'u8g_prepare' was not declared in this scope
u8g_prepare();
^~~~~~~~~~~
sketch\bitmap.cpp:778:5: note: suggested alternative: 'u8g_Delay'
u8g_prepare();
^~~~~~~~~~~
u8g_Delay
bitmap.cpp:783:5: error: 'drawIcon' was not declared in this scope
drawIcon(centerX - 8, centerY - 20, icon_num);
^~~~~~~~
sketch\bitmap.cpp: In function 'void drawMessage()':
bitmap.cpp:811:5: error: 'u8g_prepare' was not declared in this scope
u8g_prepare();
^~~~~~~~~~~
sketch\bitmap.cpp:811:5: note: suggested alternative: 'u8g_Delay'
u8g_prepare();
^~~~~~~~~~~
u8g_Delay
bitmap.cpp:816:5: error: 'drawIcon' was not declared in this scope
drawIcon(centerX - 8, centerY - 20, icon_num);
^~~~~~~~
sketch\bitmap.cpp: In function 'void drawClock()':
bitmap.cpp:841:5: error: 'u8g_prepare' was not declared in this scope
u8g_prepare();
^~~~~~~~~~~
sketch\bitmap.cpp:841:5: note: suggested alternative: 'u8g_Delay'
u8g_prepare();
^~~~~~~~~~~
u8g_Delay
bitmap.cpp:877:7: error: 'showTimePin' was not declared in this scope
showTimePin(centerY, centerY, 0.1, 0.4, iHour * 5 + (int)(iMinutes * 5 / 60));
^~~~~~~~~~~
bitmap.cpp:909:7: error: 'showTimePin' was not declared in this scope
showTimePin(centerX, centerY, 0.1, 0.5, iHour * 5 + (int)(iMinutes * 5 / 60));
^~~~~~~~~~~
sketch\bitmap.cpp: In function 'void drawIdleClock()':
bitmap.cpp:924:5: error: 'u8g_prepare' was not declared in this scope
u8g_prepare();
^~~~~~~~~~~
sketch\bitmap.cpp:924:5: note: suggested alternative: 'u8g_Delay'
u8g_prepare();
^~~~~~~~~~~
u8g_Delay
exit status 1
'HIGH' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I think the OP need to explain exactly what they are trying to do.
shalekberli:
I think .cpp file is in the .ino file
A .cpp file certainly is NOT the same as a .ino.
The IDE performs completely different steps when compiling each.
You need to explain what you are trying to achieve, and what the structure of your project is.
Take the bitmap.cpp file you posted here.
Open it in Windows Notepad.
Select all and copy it to the clipboard.
Create a new sketch (.ino) file in Arduino IDE.
Select all of the new template sketch provided (setup and loop) and delete them.