Skip to content

Commit

Permalink
Merge pull request #48 from esp-cpp/ci/build-package
Browse files Browse the repository at this point in the history
Add CI for building and uploading
  • Loading branch information
finger563 authored Dec 28, 2023
2 parents ccf788b + a692cd4 commit dce6114
Show file tree
Hide file tree
Showing 22 changed files with 224 additions and 274 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Build Examples
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.2
target: esp32s3
path: '.'
46 changes: 46 additions & 0 deletions .github/workflows/package_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Package Main

on:
push:
branches: [main]
release:
types: [published]

jobs:
build:

runs-on: ubuntu-latest
continue-on-error: false

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Build Main Code
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.2
target: esp32s3
path: '.'
command: './patches.sh && idf.py build'

- name: Upload Build Outputs
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: build/bootloader/bootloader.bin
path: build/partition_table/partition-table.bin
path: build/esp-box-emu.bin

- name: Attach files to release
uses: softprops/action-gh-release@v1
if: ${{ github.event.release && github.event.action == 'published' }}
with:
files: |
build/esp-box-emu.bin
build/bootloader/bootloader.bin
build/partition_table/partition-table.bin
build/flash_args
25 changes: 25 additions & 0 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Static analysis

on: [pull_request]

jobs:
static_analysis:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Run static analysis
uses: esp-cpp/StaticAnalysis@master
with:
# Do not build the project and do not use cmake to generate compile_commands.json
use_cmake: false

# Use the 5.2 release version since it's what we build with
esp_idf_version: release/v5.2

# (Optional) cppcheck args
cppcheck_args: -i$GITHUB_WORKSPACE/lib -i$GITHUB_WORKSPACE/components/gbc/gnuboy -i$GITHUB_WORKSPACE/components/nes/nofrendo -i$GITHUB_WORKSPACE/components/gui/generated -i$GITHUB_WORKSPACE/components/menu/generated -i$GITHUB_WORKSPACE/components/jpegdec -i$GITHUB_WORKSPACE/components/codec -i$GITHUB_WORKSPACE/components/espp --force --enable=all --inline-suppr --inconclusive --platform=mips32 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "components/jpegdec"]
path = components/jpegdec
url = [email protected]:bitbank2/JPEGDEC
[submodule "components/jpegenc"]
path = components/jpegenc
url = [email protected]:esp-cpp/JPEGENC
22 changes: 11 additions & 11 deletions components/box-emu-hal/src/i2s_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ int get_audio_volume() {

static esp_err_t i2s_driver_init(void)
{
printf("initializing i2s driver...\n");
fmt::print("initializing i2s driver...\n");
auto ret_val = ESP_OK;
printf("Using newer I2S standard\n");
fmt::print("Using newer I2S standard\n");
i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(i2s_port, I2S_ROLE_MASTER);
chan_cfg.auto_clear = true; // Auto clear the legacy data in the DMA buffer
ESP_ERROR_CHECK(i2s_new_channel(&chan_cfg, &tx_handle, &rx_handle));
Expand Down Expand Up @@ -114,7 +114,7 @@ static esp_err_t i2s_driver_init(void)
// es7210 is for audio input codec
static esp_err_t es7210_init_default(void)
{
printf("initializing es7210 codec...\n");
fmt::print("initializing es7210 codec...\n");
esp_err_t ret_val = ESP_OK;
audio_hal_codec_config_t cfg;
memset(&cfg, 0, sizeof(cfg));
Expand All @@ -131,7 +131,7 @@ static esp_err_t es7210_init_default(void)
ret_val |= es7210_adc_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);

if (ESP_OK != ret_val) {
printf("Failed initialize codec\n");
fmt::print("Failed initialize codec\n");
}

return ret_val;
Expand All @@ -140,7 +140,7 @@ static esp_err_t es7210_init_default(void)
// es8311 is for audio output codec
static esp_err_t es8311_init_default(void)
{
printf("initializing es8311 codec...\n");
fmt::print("initializing es8311 codec...\n");
esp_err_t ret_val = ESP_OK;
audio_hal_codec_config_t cfg;
memset(&cfg, 0, sizeof(cfg));
Expand All @@ -158,7 +158,7 @@ static esp_err_t es8311_init_default(void)
ret_val |= es8311_codec_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);

if (ESP_OK != ret_val) {
printf("Failed initialize codec\n");
fmt::print("Failed initialize codec\n");
}

return ret_val;
Expand Down Expand Up @@ -212,10 +212,10 @@ static void init_mute_button(void) {
.callback = [](auto &m, auto&cv) -> bool {
static gpio_num_t io_num;
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
// invert the state since these are active low switches
bool pressed = !gpio_get_level(io_num);
// see if it's the mute button
if (io_num == mute_pin) {
// invert the state since these are active low switches
bool pressed = !gpio_get_level(io_num);
// NOTE: the MUTE is actually connected to a flip-flop which holds
// state, so pressing it actually toggles the state that we see on
// the ESP pin. Therefore, when we get an edge trigger, we should
Expand Down Expand Up @@ -251,7 +251,7 @@ void audio_init() {

/* Checko IO config result */
if (ESP_OK != bsp_io_config_state) {
printf("Failed initialize power control IO\n");
fmt::print("Failed initialize power control IO\n");
}

gpio_set_level(sound_power_pin, 1);
Expand Down Expand Up @@ -282,9 +282,9 @@ void audio_play_frame(uint8_t *data, uint32_t num_bytes) {
auto err = ESP_OK;
err = i2s_channel_write(tx_handle, data, num_bytes, &bytes_written, 1000);
if(num_bytes != bytes_written) {
printf("ERROR to write %ld != written %d\n", num_bytes, bytes_written);
fmt::print("ERROR to write {} != written {}\n", num_bytes, bytes_written);
}
if (err != ESP_OK) {
printf("ERROR writing i2s channel: %d, '%s'\n", err, esp_err_to_name(err));
fmt::print("ERROR writing i2s channel: {}, '{}'\n", err, esp_err_to_name(err));
}
}
2 changes: 1 addition & 1 deletion components/gbc/src/gameboy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void start_gameboy_tasks() {
}

std::vector<uint8_t> get_gameboy_video_buffer() {
uint8_t* frame_buffer = get_frame_buffer0();
const uint8_t* frame_buffer = get_frame_buffer0();
// copy the frame buffer to a new buffer
auto width = GAMEBOY_SCREEN_WIDTH;
auto height = GAMEBOY_SCREEN_HEIGHT;
Expand Down
6 changes: 3 additions & 3 deletions components/gui/include/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Gui {
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
};

Gui(const Config& config)
explicit Gui(const Config& config)
: play_haptic_(config.play_haptic),
set_waveform_(config.set_waveform),
display_(config.display),
Expand Down Expand Up @@ -64,7 +64,7 @@ class Gui {
ready_to_play_ = new_state;
}

bool ready_to_play() {
bool ready_to_play() const {
return ready_to_play_;
}

Expand All @@ -84,7 +84,7 @@ class Gui {

void add_rom(const RomInfo& rom);

std::optional<const RomInfo*> get_selected_rom() {
std::optional<const RomInfo*> get_selected_rom() const {
if (focused_rom_ < 0 || focused_rom_ >= rom_infos_.size()) {
return std::nullopt;
}
Expand Down
2 changes: 1 addition & 1 deletion components/jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
idf_component_register(
SRC_DIRS "src"
INCLUDE_DIRS "include"
REQUIRES heap jpegdec format lvgl box-emu-hal)
REQUIRES "heap" "jpegdec" "format" "lvgl" "box-emu-hal")
6 changes: 3 additions & 3 deletions components/jpeg/include/jpeg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "spi_lcd.h"

#include "format.hpp"
#include "jpegdec.h"
#include "JPEGDEC.h"

class Jpeg {
public:
Expand Down Expand Up @@ -76,7 +76,7 @@ class Jpeg {
imgfile_.open(filename, std::ios::binary | std::ios::ate);
if (!imgfile_.is_open()) {
fmt::print("Couldn't open {}\n", filename);
size = 0;
*size = 0;
return;
}
// get size from current location (end)
Expand Down Expand Up @@ -110,7 +110,7 @@ class Jpeg {
auto ys = pDraw->y;
auto ye = pDraw->y + height - 1;
uint16_t *dst_buffer = (uint16_t*)decoded_data_;
uint16_t *src_buffer = (uint16_t*)pDraw->pPixels;
const uint16_t *src_buffer = (const uint16_t*)pDraw->pPixels;
// two bytes per pixel for RGB565
auto num_bytes_per_row = width * 2;
for (int y=ys; y<=ye; y++) {
Expand Down
1 change: 0 additions & 1 deletion components/jpegenc
Submodule jpegenc deleted from 3db39f
4 changes: 2 additions & 2 deletions components/menu/include/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Menu {
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
};

Menu(const Config& config)
explicit Menu(const Config& config)
: display_(config.display),
paused_image_path_(config.paused_image_path),
action_callback_(config.action_callback),
Expand Down Expand Up @@ -97,7 +97,7 @@ class Menu {

void set_video_setting(VideoSetting setting);

bool is_paused() { return paused_; }
bool is_paused() const { return paused_; }
void pause() {
paused_ = true;
lv_group_focus_freeze(group_, true);
Expand Down
4 changes: 2 additions & 2 deletions components/nes/src/nes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ std::vector<uint8_t> get_nes_video_buffer() {
std::vector<uint8_t> frame(NES_SCREEN_WIDTH * NES_VISIBLE_HEIGHT * 2);
// the frame data for the NES is stored in frame_buffer0 as a 8 bit index into the palette
// we need to convert this to a 16 bit RGB565 value
uint8_t *frame_buffer0 = get_frame_buffer0();
uint16_t *palette = get_nes_palette();
const uint8_t *frame_buffer0 = get_frame_buffer0();
const uint16_t *palette = get_nes_palette();
for (int i = 0; i < NES_SCREEN_WIDTH * NES_VISIBLE_HEIGHT; i++) {
uint8_t index = frame_buffer0[i];
uint16_t color = palette[index];
Expand Down
18 changes: 8 additions & 10 deletions components/nes/src/video_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void set_palette(rgb_t *pal);
static void clear(uint8 color);
static bitmap_t *lock_write(void);
static void free_write(int num_dirties, rect_t *dirty_rects);
static void custom_blit(bitmap_t *bmp, int num_dirties, rect_t *dirty_rects);
static void custom_blit(const bitmap_t *bmp, int num_dirties, rect_t *dirty_rects);

QueueHandle_t vidQueue;

Expand All @@ -134,7 +134,7 @@ viddriver_t sdlDriver =
clear, /* clear */
lock_write, /* lock_write */
free_write, /* free_write */
custom_blit, /* custom_blit */
(void (*)(bitmap_t *, int, rect_t *))custom_blit, /* custom_blit */
false /* invalidate flag */
};

Expand All @@ -149,7 +149,6 @@ void osd_set_video_scale(bool new_video_scale) {
}

void ili9341_write_frame_nes(const uint8_t* buffer, uint16_t* myPalette) {
short x, y;
static const int x_offset = (320-256)/2;
static const int y_offset = (240-224)/2;
if (buffer == NULL) {
Expand All @@ -163,11 +162,12 @@ void ili9341_write_frame_nes(const uint8_t* buffer, uint16_t* myPalette) {
lcd_write_frame(0,0,320,240,NULL);
}
if (scale_video) {
uint8_t* framePtr = buffer;
const uint8_t* framePtr = buffer;
static int buffer_index = 0;
static const int LINE_COUNT = NUM_ROWS_IN_FRAME_BUFFER;
float x_scale = 1.25f;
float y_scale = 1.0f;
short x, y;
for (y = 0; y < 240; y+= LINE_COUNT) {
uint16_t* line_buffer = buffer_index ? (uint16_t*)get_vram1() : (uint16_t*)get_vram0();
buffer_index = buffer_index ? 0 : 1;
Expand All @@ -186,9 +186,10 @@ void ili9341_write_frame_nes(const uint8_t* buffer, uint16_t* myPalette) {
lcd_write_frame(0, y_offset+y, 320, num_lines_written, (uint8_t*)&line_buffer[0]);
}
} else {
uint8_t* framePtr = buffer;
const uint8_t* framePtr = buffer;
static int buffer_index = 0;
static const int LINE_COUNT = NUM_ROWS_IN_FRAME_BUFFER;
short x, y;
for (y = 0; y < NES_GAME_HEIGHT; y+= LINE_COUNT) {
uint16_t* line_buffer = buffer_index ? (uint16_t*)get_vram1() : (uint16_t*)get_vram0();
buffer_index = buffer_index ? 0 : 1;
Expand Down Expand Up @@ -282,7 +283,7 @@ static void free_write(int num_dirties, rect_t *dirty_rects)
bmp_destroy(&myBitmap);
}

static void custom_blit(bitmap_t *bmp, int num_dirties, rect_t *dirty_rects) {
static void custom_blit(const bitmap_t *bmp, int num_dirties, rect_t *dirty_rects) {
uint8_t *lcdfb = get_frame_buffer0();
if (bmp->line[0] != NULL)
{
Expand Down Expand Up @@ -447,10 +448,7 @@ int osd_init()
{
log_chain_logfunc(logprint);

if (osd_init_sound())
{
abort();
}
osd_init_sound();

vidQueue=xQueueCreate(1, sizeof(bitmap_t *));
xTaskCreatePinnedToCore(&videoTask, "videoTask", 6*1024, NULL, 20, NULL, 1);
Expand Down
Loading

0 comments on commit dce6114

Please sign in to comment.