I'm taking some code that was made for 32u4 and trying to use it on an nRF52832.
I think it should be pretty simple (but I may be optimistic). Even if it isn't so do-able, this error I'm getting is driving me crazy, and would really appreciate finding out why it is happening.
I think all I really need to do is change which pin is used as the 'trigger' (for photo). That line what is giving me the error. I have tried a bunch of different values but keep getting this error.
error: "invalid conversion from 'int' to 'char*' [-permission]
on the line: #define TRIGGER_PIN
Really appreciate any help/advice. Thanks!
Here is the code:
/* General configuration
---------------------
INITIAL_DELAY = delay after reset to initialize serial port in ms
PERFORM_FACTORY_RESET = define to perform BT module factory reset on restart
SHUTTER_MIN_INTERVAL = minimum interval between shutter presses
*/
#define INITIAL_DELAY 1000 // ms
//#define PERFORM_FACTORY_RESET
#define SHUTTER_MIN_INTERVAL 10000 // ms
/* Interval shooting feature configuration
---------------------------------------
USE_INTERVAL = define to enable interval shooting
INTERVAL_DOT = show "." on serial every X ms
INTERVAL_SHUTTER = press shutter every X ms
*/
//#define USE_INTERVAL
#define INTERVAL_SHUTTER 30000 // ms
/* Trigger pin feature configuration
---------------------------------
USE_TRIGGER = define to enable triggered shooting
TRIGGER_ON_LH = true to trigger on switching from low to high
TRIGGER_ON_HL = true to trigger on switching from high to low
TRIGGER_PIN = GPIO pin used for trigger
*/
#define USE_TRIGGER
#define TRIGGER_PIN 5
#define TRIGGER_ON_LH true
#define TRIGGER_ON_HL false
/* Bluefruit BLE module configuration
----------------------------------
If you use the recommended board Adafruit Feather 32u4 Bluefruit LE,
(product #2829), then do not modify anything below -- these settings
are required for this board.
*/
#define BLUEFRUIT_MINIMUM_FIRMWARE_VERSION "0.6.6"
#define BLUEFRUIT_SPI_CS 8
#define BLUEFRUIT_SPI_IRQ 7
#define BLUEFRUIT_SPI_RST 4
#define BLUEFRUIT_VERBOSE_MODE false
Here is the other piece for reference:
/* Altairis PrusaCam Feather BT version 1.0.0 (2019-03-29)
Copyright (c) Michal A. Valasek - Altairis, 2019
Licensed under terms of the MIT License.
www.rider.cz | www.altairis.cz | github.com/ridercz/PrusaCam
*/
#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "PrusaCamConfig.h"
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
bool serialAvailable = false;
unsigned long nextShutterMin = 0;
#ifdef USE_INTERVAL
unsigned long nextShutterMillis = 0;
#endif
#ifdef USE_TRIGGER
bool lastTriggerState = false;
#endif
void setup() {
// Turn on LED during initialization
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, true);
// Initialize serial port
Serial.begin(9600);
while (true) {
if (Serial) {
serialAvailable = true;
break;
}
if (millis() > INITIAL_DELAY) break;
}
logPrintLn(F("Altairis PrusaCam Feather BT version 1.0.0"));
logPrintLn(F("Copyright (c) Michal A. Valasek - Altairis, 2019"));
logPrintLn(F(" www.rider.cz | www.altairis.cz | github.com/ridercz/PrusaCam"));
logPrintLn();
// Initialize Bluetooth
initBLE();
// Check if there is either interval or trigger
bool hasSomethigToRunOn = false;
#ifdef USE_TRIGGER
logPrint(F("Trigger enabled on pin "));
logPrintLn(TRIGGER_PIN);
pinMode(TRIGGER_PIN, INPUT);
if (TRIGGER_ON_LH || TRIGGER_ON_HL) {
if (TRIGGER_ON_LH) logPrintLn(F("Trigger on LH enabled."));
if (TRIGGER_ON_HL) logPrintLn(F("Trigger on HL enabled."));
hasSomethigToRunOn = true;
} else {
logPrintLn(F("WARNING: Neither TRIGGER_ON_LH nor TRIGGER_ON_HL is set to true. Trigger is effectively disabled."));
}
#endif
#ifdef USE_INTERVAL
logPrint(F("Inteval enabled, time (ms) = "));
logPrintLn(INTERVAL_SHUTTER);
hasSomethigToRunOn = true;
#endif
if (!hasSomethigToRunOn) {
logPrintLn(F("CONFIGURATION ERROR: There are no conditions for shutter defined, so the shutter will never be pressed."));
logPrintLn(F("System halted."));
while (1);
}
// Turn off LED
logPrintLn(F("Initialization done, system ready."));
digitalWrite(LED_BUILTIN, false);
}
void loop() {
#ifdef USE_TRIGGER
bool currentTriggerState = digitalRead(TRIGGER_PIN);
if (lastTriggerState != currentTriggerState) {
if (TRIGGER_ON_LH && currentTriggerState) {
logPrint("Trigger (LH) detected: ");
pressShutter();
}
if (TRIGGER_ON_HL && !currentTriggerState) {
logPrint("Trigger (HL) detected: ");
pressShutter();
}
lastTriggerState = currentTriggerState;
}
#endif
#ifdef USE_INTERVAL
// Press shutter every INTERVAL_SHUTTER ms
if (millis() >= nextShutterMillis) {
pressShutter();
logPrintLn(F("Waiting..."));
nextShutterMillis = millis() + INTERVAL_SHUTTER;
}
#endif
}
void initBLE() {
logPrint(F("Initializing the Bluetooth module..."));
if (!ble.begin(BLUEFRUIT_VERBOSE_MODE)) {
logPrintLn(F("Failed!"));
while (1);
}
logPrintLn(F("OK"));
if (serialAvailable) {
// Disable command echo
ble.echo(false);
// Display module info
ble.info();
}
#ifdef PERFORM_FACTORY_RESET
logPrint(F("Performing a factory reset..."));
if (!ble.factoryReset()) {
logPrintLn(F("Failed!"));
while (1);
}
logPrintLn(F("OK"));
#endif
// Firmware version 0.6.6+ required
if (!ble.isVersionAtLeast(BLUEFRUIT_MINIMUM_FIRMWARE_VERSION)) {
logPrintLn(F("This sketch requires firmware version "BLUEFRUIT_MINIMUM_FIRMWARE_VERSION" or higher!"));
while (1);
}
logPrint(F("Setting device name to 'Altairis PrusaCam Feather BT'..."));
if (!ble.sendCommandCheckOK(F("AT+GAPDEVNAME=Altairis PrusaCam Feather BT"))) {
logPrintLn(F("Failed!"));
while (1);
}
logPrintLn(F("OK"));
logPrint(F("Enabling HID Services..."));
if (!ble.sendCommandCheckOK(F("AT+BLEHIDEN=On"))) {
logPrintLn(F("Failed!"));
while (1);
}
logPrintLn(F("OK"));
logPrint(F("Applying changes..."));
if (!ble.reset()) {
logPrintLn(F("Failed!"));
while (1);
}
logPrintLn(F("OK"));
}
void pressShutter() {
if (millis() < nextShutterMin) {
logPrintLn(F("Ignoring shutter request, too early after previous one."));
return;
}
// Turn on LED during shutter press
digitalWrite(LED_BUILTIN, true);
// Send VOLUME+
logPrint(F("Pressing shutter..."));
ble.println(F("AT+BleHidControlKey=VOLUME+"));
if (!ble.waitForOK()) {
logPrintLn(F("Failed! (maybe not paired?)"));
} else {
logPrintLn(F("OK"));
}
// Turn off LED
digitalWrite(LED_BUILTIN, false);
// Set minimum time for next shutter
nextShutterMin = millis() + SHUTTER_MIN_INTERVAL;
}
void logPrintLn() {
if (!serialAvailable) return;
Serial.println();
}
void logPrintLn(char* s) {
if (!serialAvailable) return;
Serial.println(s);
}
void logPrintLn(String s) {
if (!serialAvailable) return;
Serial.println(s);
}
void logPrint(String s) {
if (!serialAvailable) return;
Serial.print(s);
}
void logPrint(char* s) {
if (!serialAvailable) return;
Serial.print(s);
}
error: "invalid conversion from 'int' to 'char*' [-permission]
on the line: #define TRIGGER_PIN
Very strange! I can't see how that line could produce that error, I wonder why it appears to. Please post the full output from the compiler, in code tags.
Arduino: 1.8.13 (Windows 10), Board: "Adafruit Feather nRF52832, 0.3.2 SoftDevice s132 6.1.1, Level 0 (Release)"
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:42,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/common_header.h:74:20: error: redefinition of 'bool is_within(uint32_t, uint32_t, uint32_t)'
74 | static inline bool is_within(uint32_t lower, uint32_t value, uint32_t upper)
| ^~~~~~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/rtos.h:45,
from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:48,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/common_func.h:312:20: note: 'bool is_within(uint32_t, uint32_t, uint32_t)' previously defined here
312 | static inline bool is_within(uint32_t lower, uint32_t value, uint32_t upper)
| ^~~~~~~~~
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:112:53: error: 'ERROR_NONE' conflicts with a previous declaration
112 | ERROR_NONE = 0x0000, ///< Successful command
| ^~~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:65:3: note: previous declaration '<unnamed enum> ERROR_NONE'
65 | ERROR_NONE = 0
| ^~~~~~~~~~
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:196:3: error: conflicting declaration 'typedef enum err_t err_t'
196 | } err_t;
| ^~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:61:18: note: previous declaration as 'typedef uint32_t err_t'
61 | typedef uint32_t err_t;
| ^~~~~
In file included from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:11:
C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino: In function 'void setup()':
PrusaCamConfig.h:28:45: error: invalid conversion from 'int' to 'char*' [-fpermissive]
28 | #define TRIGGER_PIN 5
| ^
| |
| int
C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:53:14: note: in expansion of macro 'TRIGGER_PIN'
53 | logPrintLn(TRIGGER_PIN);
| ^~~~~~~~~~~
C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:189:23: note: initializing argument 1 of 'void logPrintLn(char*)'
189 | void logPrintLn(char* s) {
| ~~~~~~^
exit status 1
invalid conversion from 'int' to 'char*' [-fpermissive]
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I made the change suggested by Paul, and it cleared that error! (Thanks!).
I am now getting a 'Error compiling board Adafruit Feather nRF52832'. Probably something else in the code that was meant for the 32u4 that needs to change, that I'm trying to figure out now (or, if it's not something simple, I may just break down and get a 32u4 board ).
full error:
Arduino: 1.8.13 (Windows 10), Board: "Adafruit Feather nRF52832, 0.3.2 SoftDevice s132 6.1.1, Level 0 (Release)"
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:42,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/common_header.h:74:20: error: redefinition of 'bool is_within(uint32_t, uint32_t, uint32_t)'
74 | static inline bool is_within(uint32_t lower, uint32_t value, uint32_t upper)
| ^~~~~~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/rtos.h:45,
from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:48,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/common_func.h:312:20: note: 'bool is_within(uint32_t, uint32_t, uint32_t)' previously defined here
312 | static inline bool is_within(uint32_t lower, uint32_t value, uint32_t upper)
| ^~~~~~~~~
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:112:53: error: 'ERROR_NONE' conflicts with a previous declaration
112 | ERROR_NONE = 0x0000, ///< Successful command
| ^~~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:65:3: note: previous declaration '<unnamed enum> ERROR_NONE'
65 | ERROR_NONE = 0
| ^~~~~~~~~~
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:196:3: error: conflicting declaration 'typedef enum err_t err_t'
196 | } err_t;
| ^~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:61:18: note: previous declaration as 'typedef uint32_t err_t'
61 | typedef uint32_t err_t;
| ^~~~~
exit status 1
Error compiling for board Adafruit Feather nRF52832.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Are those "ERROR_NONE" actually errors that need to be cleared, or just the "err_t"s?
Arduino: 1.8.13 (Windows 10), Board: "Adafruit Feather nRF52832, 0.3.2 SoftDevice s132 6.1.1, Level 0 (Release)"
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:112:53: error: 'ERROR_NONE' conflicts with a previous declaration
112 | ERROR_NONE = 0x0000, ///< Successful command
| ^~~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:65:3: note: previous declaration '<unnamed enum> ERROR_NONE'
65 | ERROR_NONE = 0
| ^~~~~~~~~~
In file included from D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/Adafruit_BLE.h:43,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:9:
D:\Documents\Arduino\libraries\Adafruit_BluefruitLE_nRF51/utility/errors.h:196:3: error: conflicting declaration 'typedef enum err_t err_t'
196 | } err_t;
| ^~~~~
In file included from C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/Arduino.h:26,
from C:\Users\David-Test\Downloads\PrusaCam-master\PrusaCamFeatherBT\PrusaCamFeatherBT.ino:7:
C:\Users\David-Test\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5/wiring_constants.h:61:18: note: previous declaration as 'typedef uint32_t err_t'
61 | typedef uint32_t err_t;
| ^~~~~
exit status 1
Error compiling for board Adafruit Feather nRF52832.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Warnings can be ignored, but errors must be corrected in order to build & upload a sketch to the board.
For that error just fixed and the remaining ones, the problem is identical and duplicated definitions in two files, one file from the adafruit nrf52 libraries and the other from the adafruit nrf52 core files. Both from adafruit, which they should fix.
Are you sure you are using the latest nrf52 core version and the latest nrf52 library versions from adafruit? They may have fixed these errors.