Closed hallvardkristiansen closed 1 year ago
Are you including the Arduino library? (I don't know if there's RP2040 support). It looks like this library is calling Arduino functions that don't exist
Sure thing! Everything not related to the ADC is working as it should.
Explicitly including Arduino.h doesn't make a difference. Then again, the arduino stuff should be there from the platform.io config file I would think?
The adc.h file I am including is for an unused onboard ADC on the picoadk board.
[env:PicoADK]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
lib_deps =
bodmer/TFT_eSPI@^2.5.21
nerdyscout/MCP3x6x@^0.0.1
build_unflags = -fno-exceptions
build_flags = blahblah
Here is the full main.cpp:
#include <TFT_eSPI.h>
#include <SPI.h>
#include <Wire.h>
TFT_eSPI tft = TFT_eSPI();
SPISettings spiSettingsBoardADC(16000000, MSBFIRST, SPI_MODE2);
SPISettings spiSettingsExtDAC(20000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsExtADC(20000000, MSBFIRST, SPI_MODE0);
#include "lib/MCP3x6x/MCP3x6x.h"
MCP3464 ext_mcp_adc(ADC_CS_PIN, &SPI, ADC_MOSI_PIN, ADC_MISO_PIN, ADC_SCK_PIN);
#include <adc.h>
#include <dac.h>
using namespace std;
#include <globals.h>
#include <functions.h>
void setup() {
Serial.begin();
Wire.begin();
SPI.begin();
SPI1.begin();
delay(100);
configurePins();
initialize_gpio_mcp();
initialize_ext_dac();
tft.init();
tft.setRotation(2);
tft.fillScreen(TFT_BLACK);
ext_mcp_adc.begin();
ext_mcp_adc.enableScanChannel(MCP_CH0);
ext_mcp_adc.enableScanChannel(MCP_CH1);
ext_mcp_adc.enableScanChannel(MCP_CH2);
ext_mcp_adc.enableScanChannel(MCP_CH3);
ext_mcp_adc.enableScanChannel(MCP_CH4);
ext_mcp_adc.enableScanChannel(MCP_CH5);
ext_mcp_adc.enableScanChannel(MCP_CH6);
ext_mcp_adc.enableScanChannel(MCP_CH7);
ext_mcp_adc.startContinuous();
}
long lastDraw1 = guiStatus0.centiHertz;
long lastDraw2 = 0;
void loop() {
millisTime = millis() % 1000; // Reset to zero every second
microsTime = micros() % 1000000;
readEncoders();
if (millisTime - displayTime >= DISPLAY_HZ_MS) {
readButtons();
displayTime = millisTime;
char buffer [33];
tft.setTextSize(1);
tft.setTextColor(TFT_BLACK, TFT_BLACK);
tft.drawString(itoa(lastDraw1, buffer, 10), 0, 0, 2);
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.drawString(itoa(guiStatus0.centiHertz, buffer, 10), 0, 0, 2);
int32_t adcdata0 = ext_mcp_adc.analogReadContinuous(MCP_CH0);
tft.setTextColor(TFT_BLACK, TFT_BLACK);
tft.drawString(itoa(lastDraw2, buffer, 10), 0, 16, 2);
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.drawString(itoa(adcdata0, buffer, 10), 0, 16, 2);
lastDraw1 = guiStatus0.centiHertz;
lastDraw2 = adcdata0;
}
}
Are your includes in order? As far as I know, the SPI library should be included before TFT
Ah, well, yeah I guess it should be, but it is also included from within the tft_espi library, so it doesn't make any difference. I swapped them around now and that doesn't change anything.
Are you building with GCC or an IDE?
I am building with platform.io in vscode, it is using GCC?
I'm not familiar with how platformio works in vscode, but how did you install the library/where did the 0.0.1 version number come from?
Otherwise, check if the examples work. If those don't, I'm stumped since everything else looks to be set up correctly
I have tried installing it via the platform.io library manager and manually copying the code from this repo, which gave me the same result. V0.0.1 is what is given in the platform.io library manager version.
I believe it has something to do with how the core is written for Arduino. May have to ask Earle Philhower. Will also test the examples, but I expect the same result since there isn't really that much difference. Worth testing anyway :)
Ah. The installation of the library via the platform.io library manager seems to be bad. I redid it entirely manually and uninstalled the one in the library manager and now it works...
Hi! I'm having some trouble compiling my code after adding this library. Most likely I'm doing something dumb, but would appreciate any input.
I include and initialise it like this:
Then I get the following errors:
(and so on)
I have some other peripherals on the two SPI channels which are working fine, an OLED and a DAC.