Skip to content

Commit

Permalink
removed namespacing around box hal constants
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 committed Jan 16, 2024
1 parent 59f2ea5 commit 1f31c9c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 34 deletions.
15 changes: 6 additions & 9 deletions components/box-emu-hal/include/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "touchpad_input.hpp"
#include "tt21100.hpp"

namespace box_hal {

static constexpr std::string_view dev_kit = "ESP32-S3-BOX";

// internal i2c (touchscreen, audio codec)
Expand All @@ -29,12 +27,12 @@ static constexpr gpio_num_t external_i2c_scl = GPIO_NUM_40;
// LCD
static constexpr int lcd_clock_speed = 60 * 1000 * 1000;
static constexpr auto lcd_spi_num = SPI2_HOST;
static constexpr gpio_num_t lcd_cs = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc = GPIO_NUM_4;
static constexpr gpio_num_t backlight = GPIO_NUM_45;
static constexpr gpio_num_t lcd_cs_io = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi_io = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk_io = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset_io = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc_io = GPIO_NUM_4;
static constexpr gpio_num_t backlight_io = GPIO_NUM_45;
static constexpr size_t display_width = 320;
static constexpr size_t display_height = 240;
static constexpr bool backlight_value = true;
Expand Down Expand Up @@ -72,4 +70,3 @@ static constexpr gpio_num_t sdcard_miso = GPIO_NUM_13;
static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12;
static constexpr auto sdcard_spi_num = SPI3_HOST;

} // namespace box_hal
16 changes: 6 additions & 10 deletions components/box-emu-hal/include/box_3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "touchpad_input.hpp"
#include "gt911.hpp"

namespace box_hal {

static constexpr std::string_view dev_kit = "ESP32-S3-BOX-3";

// internal i2c (touchscreen, audio codec)
Expand All @@ -29,12 +27,12 @@ static constexpr gpio_num_t external_i2c_scl = GPIO_NUM_40;
// LCD
static constexpr int lcd_clock_speed = 60 * 1000 * 1000;
static constexpr auto lcd_spi_num = SPI2_HOST;
static constexpr gpio_num_t lcd_cs = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc = GPIO_NUM_4;
static constexpr gpio_num_t backlight = GPIO_NUM_47; // was 45 on ESP32-S3-BOX
static constexpr gpio_num_t lcd_cs_io = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi_io = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk_io = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset_io = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc_io = GPIO_NUM_4;
static constexpr gpio_num_t backlight_io = GPIO_NUM_47; // was 45 on ESP32-S3-BOX
static constexpr size_t display_width = 320;
static constexpr size_t display_height = 240;
static constexpr bool backlight_value = true;
Expand Down Expand Up @@ -71,5 +69,3 @@ static constexpr gpio_num_t sdcard_mosi = GPIO_NUM_11;
static constexpr gpio_num_t sdcard_miso = GPIO_NUM_13;
static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12;
static constexpr auto sdcard_spi_num = SPI3_HOST;

} // namespace box_hal
1 change: 0 additions & 1 deletion components/box-emu-hal/src/fs_init.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "fs_init.hpp"

using namespace box_hal;
static sdmmc_card_t *sdcard = nullptr;

static void sdcard_init() {
Expand Down
2 changes: 0 additions & 2 deletions components/box-emu-hal/src/hal_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ static std::shared_ptr<espp::I2c> external_i2c = nullptr;

static bool initialized = false;

using namespace box_hal;

void hal::i2c_init() {
if (initialized) return;
// make the i2c on core 1 so that the i2c interrupts are handled on core 1
Expand Down
2 changes: 0 additions & 2 deletions components/box-emu-hal/src/i2s_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "hal.hpp"
#include "hal_i2c.hpp"

using namespace box_hal;

/**
* Look at
* https://github.com/espressif/esp-idf/blob/master/examples/peripherals/i2s/i2s_codec/i2s_es8311/main/i2s_es8311_example.c
Expand Down
1 change: 0 additions & 1 deletion components/box-emu-hal/src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "hal_i2c.hpp"

using namespace std::chrono_literals;
using namespace box_hal;

struct TouchpadData {
uint8_t num_touch_points = 0;
Expand Down
16 changes: 7 additions & 9 deletions components/box-emu-hal/src/spi_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "hal/spi_types.h"
#include "driver/spi_master.h"

using namespace box_hal;

static spi_device_handle_t spi;
static spi_device_interface_config_t devcfg;

Expand Down Expand Up @@ -32,7 +30,7 @@ static void IRAM_ATTR lcd_spi_pre_transfer_callback(spi_transaction_t *t)
{
uint32_t user_flags = (uint32_t)(t->user);
bool dc_level = user_flags & DC_LEVEL_BIT;
gpio_set_level(lcd_dc, dc_level);
gpio_set_level(lcd_dc_io, dc_level);
}

// This function is called (in irq context!) just after a transmission ends. It
Expand Down Expand Up @@ -197,9 +195,9 @@ extern "C" void lcd_init() {

spi_bus_config_t buscfg;
memset(&buscfg, 0, sizeof(buscfg));
buscfg.mosi_io_num = lcd_mosi;
buscfg.mosi_io_num = lcd_mosi_io;
buscfg.miso_io_num = -1;
buscfg.sclk_io_num = lcd_sclk;
buscfg.sclk_io_num = lcd_sclk_io;
buscfg.quadwp_io_num = -1;
buscfg.quadhd_io_num = -1;
buscfg.max_transfer_sz = frame_buffer_size * sizeof(lv_color_t) + 100;
Expand All @@ -209,7 +207,7 @@ extern "C" void lcd_init() {
// devcfg.flags = SPI_DEVICE_NO_RETURN_RESULT;
devcfg.clock_speed_hz = lcd_clock_speed;
devcfg.input_delay_ns = 0;
devcfg.spics_io_num = lcd_cs;
devcfg.spics_io_num = lcd_cs_io;
devcfg.queue_size = spi_queue_size;
devcfg.pre_cb = lcd_spi_pre_transfer_callback;
devcfg.post_cb = lcd_spi_post_transfer_callback;
Expand All @@ -224,8 +222,8 @@ extern "C" void lcd_init() {
DisplayDriver::initialize(espp::display_drivers::Config{
.lcd_write = lcd_write,
.lcd_send_lines = lcd_send_lines,
.reset_pin = lcd_reset,
.data_command_pin = lcd_dc,
.reset_pin = lcd_reset_io,
.data_command_pin = lcd_dc_io,
.reset_value = reset_value,
.invert_colors = invert_colors,
.mirror_x = mirror_x,
Expand All @@ -238,7 +236,7 @@ extern "C" void lcd_init() {
.height = display_height,
.pixel_buffer_size = pixel_buffer_size,
.flush_callback = DisplayDriver::flush,
.backlight_pin = backlight,
.backlight_pin = backlight_io,
.backlight_on_value = backlight_value,
.stack_size_bytes = 4*1024,
.update_period = 5ms,
Expand Down

0 comments on commit 1f31c9c

Please sign in to comment.