Repository navigation
Add heltec rcc6 #2981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Quency-D
wants to merge
4
commits into
meshcore-dev:dev
Choose a base branch
from
Quency-D:heltec-rcc6
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add heltec rcc6 #2981
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "build": { | ||
| "arduino": { | ||
| "partitions": "default_16MB.csv" | ||
| }, | ||
| "core": "esp32", | ||
| "f_cpu": "160000000L", | ||
| "f_flash": "80000000L", | ||
| "flash_mode": "qio", | ||
| "hwids": [["0x303A", "0x1001"]], | ||
| "mcu": "esp32c6", | ||
| "variant": "heltec_rcc6" | ||
| }, | ||
| "connectivity": ["bluetooth", "wifi", "lora"], | ||
| "debug": { | ||
| "openocd_target": "esp32c6.cfg" | ||
| }, | ||
| "frameworks": ["arduino", "espidf"], | ||
| "name": "heltec_rcc6", | ||
| "upload": { | ||
| "flash_size": "16MB", | ||
| "maximum_ram_size": 327680, | ||
| "maximum_size": 16777216, | ||
| "require_upload_port": true, | ||
| "speed": 921600 | ||
| }, | ||
| "url": "https://heltec.org/", | ||
| "vendor": "heltec" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,14 @@ | |
| #include <Arduino.h> | ||
| #include <string.h> | ||
|
|
||
| #if NV3001B_USE_FAST_GPIO | ||
| #if !defined(CONFIG_IDF_TARGET_ESP32C6) | ||
| #error "NV3001B_USE_FAST_GPIO is only supported on ESP32-C6" | ||
| #endif | ||
| #include <hal/gpio_ll.h> | ||
| #include <soc/gpio_struct.h> | ||
| #endif | ||
|
|
||
| #ifndef SPI_FREQUENCY | ||
| #define SPI_FREQUENCY 8000000 | ||
| #endif | ||
|
|
@@ -200,26 +208,75 @@ static void writeOptionalPin(int pin, int level) { | |
| digitalWrite(pin, level); | ||
| } | ||
|
|
||
| void NV3001BDisplay::writeCommand(uint8_t cmd) { | ||
| void NV3001BDisplay::beginTransport() { | ||
| #if NV3001B_USE_SOFTWARE_SPI | ||
| pinMode(PIN_TFT_SCL, OUTPUT); | ||
| pinMode(PIN_TFT_SDA, OUTPUT); | ||
| digitalWrite(PIN_TFT_SCL, LOW); | ||
| digitalWrite(PIN_TFT_SDA, LOW); | ||
| #elif defined(NRF52_PLATFORM) | ||
| spi.begin(); | ||
| #elif defined(ESP_PLATFORM) || defined(ESP32_PLATFORM) | ||
| spi.begin(PIN_TFT_SCL, PIN_TFT_MISO, PIN_TFT_SDA, PIN_TFT_CS); | ||
| #else | ||
| spi.begin(); | ||
| #endif | ||
| } | ||
|
|
||
| void NV3001BDisplay::beginTransfer() { | ||
| #if NV3001B_USE_SOFTWARE_SPI | ||
| digitalWrite(PIN_TFT_SCL, LOW); | ||
| #else | ||
| spi.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0)); | ||
| #endif | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking and major change. |
||
| } | ||
|
|
||
| void NV3001BDisplay::transferByte(uint8_t value) { | ||
| #if NV3001B_USE_SOFTWARE_SPI | ||
| for (uint8_t mask = 0x80; mask != 0; mask >>= 1) { | ||
| #if NV3001B_USE_FAST_GPIO | ||
| gpio_ll_set_level(&GPIO, PIN_TFT_SDA, (value & mask) ? HIGH : LOW); | ||
| gpio_ll_set_level(&GPIO, PIN_TFT_SCL, HIGH); | ||
| gpio_ll_set_level(&GPIO, PIN_TFT_SCL, LOW); | ||
| #else | ||
| digitalWrite(PIN_TFT_SDA, (value & mask) ? HIGH : LOW); | ||
| digitalWrite(PIN_TFT_SCL, HIGH); | ||
| digitalWrite(PIN_TFT_SCL, LOW); | ||
| #endif | ||
| } | ||
| #else | ||
| spi.transfer(value); | ||
| #endif | ||
| } | ||
|
|
||
| void NV3001BDisplay::endTransfer() { | ||
| #if NV3001B_USE_SOFTWARE_SPI | ||
| digitalWrite(PIN_TFT_SCL, LOW); | ||
| #else | ||
| spi.endTransaction(); | ||
| #endif | ||
| } | ||
|
|
||
| void NV3001BDisplay::writeCommand(uint8_t cmd) { | ||
| beginTransfer(); | ||
| digitalWrite(PIN_TFT_DC, LOW); | ||
| digitalWrite(PIN_TFT_CS, LOW); | ||
| spi.transfer(cmd); | ||
| transferByte(cmd); | ||
| digitalWrite(PIN_TFT_CS, HIGH); | ||
| spi.endTransaction(); | ||
| endTransfer(); | ||
| } | ||
|
|
||
| void NV3001BDisplay::writeBytes(const uint8_t* data, size_t len) { | ||
| if (!data || len == 0) return; | ||
|
|
||
| spi.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0)); | ||
| beginTransfer(); | ||
| digitalWrite(PIN_TFT_DC, HIGH); | ||
| digitalWrite(PIN_TFT_CS, LOW); | ||
| for (size_t i = 0; i < len; i++) { | ||
| spi.transfer(data[i]); | ||
| transferByte(data[i]); | ||
| } | ||
| digitalWrite(PIN_TFT_CS, HIGH); | ||
| spi.endTransaction(); | ||
| endTransfer(); | ||
| } | ||
|
|
||
| void NV3001BDisplay::writeCommandData(uint8_t cmd, const uint8_t* data, size_t len) { | ||
|
|
@@ -251,15 +308,15 @@ void NV3001BDisplay::writeColor(uint16_t rgb, uint32_t count) { | |
| uint8_t hi = rgb >> 8; | ||
| uint8_t lo = rgb & 0xff; | ||
|
|
||
| spi.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0)); | ||
| beginTransfer(); | ||
| digitalWrite(PIN_TFT_DC, HIGH); | ||
| digitalWrite(PIN_TFT_CS, LOW); | ||
| while (count--) { | ||
| spi.transfer(hi); | ||
| spi.transfer(lo); | ||
| transferByte(hi); | ||
| transferByte(lo); | ||
| } | ||
| digitalWrite(PIN_TFT_CS, HIGH); | ||
| spi.endTransaction(); | ||
| endTransfer(); | ||
| } | ||
|
|
||
| void NV3001BDisplay::initPanel() { | ||
|
|
@@ -425,7 +482,7 @@ bool NV3001BDisplay::begin() { | |
| digitalWrite(PIN_TFT_DC, HIGH); | ||
| delay(20); | ||
|
|
||
| spi.begin(PIN_TFT_SCL, PIN_TFT_MISO, PIN_TFT_SDA, PIN_TFT_CS); | ||
| beginTransport(); | ||
| if (PIN_TFT_RST >= 0) { | ||
| pinMode(PIN_TFT_RST, OUTPUT); | ||
| digitalWrite(PIN_TFT_RST, HIGH); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,25 @@ | ||
| #pragma once | ||
|
|
||
| #include "DisplayDriver.h" | ||
| #include <SPI.h> | ||
| #include <helpers/RefCountedDigitalPin.h> | ||
|
|
||
| #ifndef NV3001B_USE_SOFTWARE_SPI | ||
| #define NV3001B_USE_SOFTWARE_SPI 0 | ||
| #endif | ||
|
|
||
| #ifndef NV3001B_USE_FAST_GPIO | ||
| #define NV3001B_USE_FAST_GPIO 0 | ||
| #endif | ||
|
|
||
| #if NV3001B_USE_FAST_GPIO && !NV3001B_USE_SOFTWARE_SPI | ||
| #error "NV3001B_USE_FAST_GPIO requires NV3001B_USE_SOFTWARE_SPI" | ||
| #endif | ||
|
|
||
| #if !NV3001B_USE_SOFTWARE_SPI | ||
| #include <cstddef> | ||
| #include <SPI.h> | ||
| #endif | ||
|
|
||
| #ifndef NV3001B_LOGICAL_WIDTH | ||
| #define NV3001B_LOGICAL_WIDTH 128 | ||
| #endif | ||
|
|
@@ -20,19 +36,27 @@ | |
| #define NV3001B_PANEL_HEIGHT 220 | ||
| #endif | ||
|
|
||
| class NV3001BDisplay : public DisplayDriver { | ||
| #if !NV3001B_USE_SOFTWARE_SPI | ||
| #if defined(ESP_PLATFORM) || defined(ESP32_PLATFORM) | ||
| #ifndef NV3001B_SPI_HOST | ||
| #define NV3001B_SPI_HOST HSPI | ||
| #endif | ||
|
|
||
| class NV3001BDisplay : public DisplayDriver { | ||
| SPIClass spi; | ||
| SPIClass owned_spi; | ||
| #endif | ||
| SPIClass& spi; | ||
| #endif | ||
| RefCountedDigitalPin* periph_power; | ||
| bool is_on = false; | ||
| uint16_t color = 0xffff; | ||
| uint8_t text_size = 1; | ||
| int cursor_x = 0; | ||
| int cursor_y = 0; | ||
|
|
||
| void beginTransport(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking and major change. |
||
| void beginTransfer(); | ||
| void transferByte(uint8_t value); | ||
| void endTransfer(); | ||
| void writeCommand(uint8_t cmd); | ||
| void writeBytes(const uint8_t* data, size_t len); | ||
| void writeCommandData(uint8_t cmd, const uint8_t* data, size_t len); | ||
|
|
@@ -43,8 +67,23 @@ class NV3001BDisplay : public DisplayDriver { | |
| void drawChar(int x, int y, char ch); | ||
|
|
||
| public: | ||
| #if NV3001B_USE_SOFTWARE_SPI | ||
| NV3001BDisplay(RefCountedDigitalPin* power = nullptr) : | ||
| DisplayDriver(NV3001B_LOGICAL_WIDTH, NV3001B_LOGICAL_HEIGHT), spi(NV3001B_SPI_HOST), periph_power(power) { } | ||
| DisplayDriver(NV3001B_LOGICAL_WIDTH, NV3001B_LOGICAL_HEIGHT), periph_power(power) { } | ||
| #elif defined(ESP_PLATFORM) || defined(ESP32_PLATFORM) | ||
| NV3001BDisplay(RefCountedDigitalPin* power = nullptr) : | ||
| DisplayDriver(NV3001B_LOGICAL_WIDTH, NV3001B_LOGICAL_HEIGHT), | ||
| owned_spi(NV3001B_SPI_HOST), spi(owned_spi), periph_power(power) { } | ||
|
|
||
| NV3001BDisplay(std::nullptr_t) : NV3001BDisplay() { } | ||
|
|
||
| NV3001BDisplay(SPIClass* displaySpi, RefCountedDigitalPin* power = nullptr) : | ||
| DisplayDriver(NV3001B_LOGICAL_WIDTH, NV3001B_LOGICAL_HEIGHT), | ||
| owned_spi(NV3001B_SPI_HOST), spi(displaySpi ? *displaySpi : owned_spi), periph_power(power) { } | ||
| #else | ||
| NV3001BDisplay(SPIClass* displaySpi = &SPI, RefCountedDigitalPin* power = nullptr) : | ||
| DisplayDriver(NV3001B_LOGICAL_WIDTH, NV3001B_LOGICAL_HEIGHT), spi(displaySpi ? *displaySpi : SPI), periph_power(power) { } | ||
| #endif | ||
|
|
||
| bool begin(); | ||
| static const char* driverName() { return "NV3001B"; } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #include "heltec_rcc6.h" | ||
|
|
||
| void HeltecRCC6Board::begin() { | ||
| ESP32Board::begin(); | ||
|
|
||
| pinMode(PIN_USER_BTN, INPUT_PULLUP); | ||
|
|
||
| pinMode(PIN_ADC_CTRL, OUTPUT); | ||
| digitalWrite(PIN_ADC_CTRL, LOW); | ||
|
|
||
| if (esp_reset_reason() == ESP_RST_DEEPSLEEP) { | ||
| gpio_hold_dis((gpio_num_t)P_LORA_NSS); | ||
| if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_GPIO && | ||
| gpio_get_level((gpio_num_t)P_LORA_DIO_1) == HIGH) { | ||
| startup_reason = BD_STARTUP_RX_PACKET; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void HeltecRCC6Board::powerOff() { | ||
| enterDeepSleep(0); | ||
| } | ||
|
|
||
| uint16_t HeltecRCC6Board::getBattMilliVolts() { | ||
| analogReadResolution(12); | ||
| analogSetAttenuation(ADC_2_5db); | ||
| digitalWrite(PIN_ADC_CTRL, ADC_CTRL_ENABLED); | ||
| delay(10); | ||
| uint32_t raw = 0; | ||
| for (int i = 0; i < 8; i++) { | ||
| raw += analogReadMilliVolts(PIN_VBAT_READ); | ||
| } | ||
| raw = raw / 8; | ||
| digitalWrite(PIN_ADC_CTRL, !ADC_CTRL_ENABLED); | ||
|
|
||
| return (adcMultiplier * raw); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #pragma once | ||
|
|
||
| #include <Arduino.h> | ||
| #include <helpers/ESP32Board.h> | ||
|
|
||
| #ifndef ADC_MULTIPLIER | ||
| #define ADC_MULTIPLIER 4.95f | ||
| #endif | ||
|
|
||
| class HeltecRCC6Board : public ESP32Board { | ||
| float adcMultiplier = ADC_MULTIPLIER; | ||
|
|
||
| public: | ||
| void begin(); | ||
| void powerOff() override; | ||
| uint16_t getBattMilliVolts() override; | ||
|
|
||
| bool setAdcMultiplier(float multiplier) override { | ||
| adcMultiplier = multiplier == 0.0f ? ADC_MULTIPLIER : multiplier; | ||
| return true; | ||
| } | ||
|
|
||
| float getAdcMultiplier() const override { return adcMultiplier; } | ||
| const char *getManufacturerName() const override { return "heltec_rcc6"; } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #ifndef PINS_ARDUINO_H | ||
| #define PINS_ARDUINO_H | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #define USB_VID 0x303A | ||
| #define USB_PID 0x1001 | ||
|
|
||
| static const uint8_t TX = 16; | ||
| static const uint8_t RX = 17; | ||
|
|
||
| static const int8_t SDA = -1; | ||
| static const int8_t SCL = -1; | ||
|
|
||
| static const uint8_t MISO = 20; | ||
| static const uint8_t SCK = 21; | ||
| static const uint8_t MOSI = 22; | ||
| static const uint8_t SS = 23; | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking and major change.
It breaks the PR of rc52.