Open heman22union opened 1 year ago
If I remove the #include
//#include <Arduino.h>
static const char* bin2tristate(const char* bin);
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength);
void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) {
const char* b = dec2binWzerofill(decimal, length);
Serial.print("Decimal: ");
Serial.print(decimal);
Serial.print(" (");
Serial.print( length );
Serial.print("Bit) Binary: ");
Serial.print( b );
Serial.print(" Tri-State: ");
Serial.print( bin2tristate( b) );
Serial.print(" PulseLength: ");
Serial.print(delay);
Serial.print(" microseconds");
Serial.print(" Protocol: ");
Serial.println(protocol);
Serial.print("Raw data: ");
for (unsigned int i=0; i<= length*2; i++) {
Serial.print(raw[i]);
Serial.print(",");
}
Serial.println();
Serial.println();
}
static const char* bin2tristate(const char* bin) {
static char returnValue[50];
int pos = 0;
int pos2 = 0;
while (bin[pos]!='\0' && bin[pos+1]!='\0') {
if (bin[pos]=='0' && bin[pos+1]=='0') {
returnValue[pos2] = '0';
} else if (bin[pos]=='1' && bin[pos+1]=='1') {
returnValue[pos2] = '1';
} else if (bin[pos]=='0' && bin[pos+1]=='1') {
returnValue[pos2] = 'F';
} else {
return "not applicable";
}
pos = pos+2;
pos2++;
}
returnValue[pos2] = '\0';
return returnValue;
}
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) {
static char bin[64];
unsigned int i=0;
while (Dec > 0) {
bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0';
Dec = Dec >> 1;
}
for (unsigned int j = 0; j< bitLength; j++) {
if (j >= bitLength - i) {
bin[j] = bin[ 31 + i - (j - (bitLength - i)) ];
} else {
bin[j] = '0';
}
}
bin[bitLength] = '\0';
return bin;
}
platformio terminal output
* Executing task in folder esp_doorbell: C:\Users\Heman\.platformio\penv\Scripts\platformio.exe run --target upload --environment nanoatmega328_test_rec
Processing nanoatmega328_test_rec (platform: atmelavr; board: nanoatmega328; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR (4.1.0) > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.1.0
- tool-avrdude @ 1.60300.200527 (6.3.0)
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- rc-switch @ 2.6.4
Building in release mode
Compiling .pio\build\nanoatmega328_test_rec\src\test_rec\ReceiveDemo_Advanced.cpp.o
Compiling .pio\build\nanoatmega328_test_rec\src\test_rec\output.cpp.o
src\test_rec\output.cpp: In function 'void output(long unsigned int, unsigned int, unsigned int, unsigned int*, unsigned int)':
src\test_rec\output.cpp:10:3: error: 'Serial' was not declared in this scope
Serial.print("Decimal: ");
^~~~~~
src\test_rec\output.cpp:10:3: note: suggested alternative: 'decimal'
Serial.print("Decimal: ");
^~~~~~
decimal
*** [.pio\build\nanoatmega328_test_rec\src\test_rec\output.cpp.o] Error 1
============================================================================================= [FAILED] Took 0.73 seconds =============================================================================================
Environment Status Duration
---------------------- -------- ------------
nanoatmega328_test_rec FAILED 00:00:00.729
======================================================================================= 1 failed, 0 succeeded in 00:00:00.729 =======================================================================================
* The terminal process "C:\Users\Heman\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--environment', 'nanoatmega328_test_rec'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
I'm trying to get the ReceiveDemo_Advanced example to work with Platform.IO and VS Code. I'm able to get it to work with the Arduino IDE, but I prefer VS Code.
Here is what I have including adding of the #include to both files? It seems I need to add to the output.cpp file too?
.\test_rec\ReceiveDemo_Advanced.cpp file
.\test_rec\output.cpp file
platform.io terminal output
platformio.ini file