Skip to content

Commit c415e1a

Browse files
authored
Merge pull request #31 from Nicolai-Electronics/renze/repository
Repository browser
2 parents 9933750 + 905096e commit c415e1a

58 files changed

Lines changed: 2282 additions & 1007 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if(DEVICE STREQUAL "")
66
set(DEVICE "$ENV{TARGET}")
77
endif()
88

9+
if(FAT STREQUAL "")
10+
set(FAT "$ENV{FAT}")
11+
endif()
12+
913
if(DEVICE STREQUAL "")
1014
message(FATAL_ERROR "DEVICE not set")
1115
endif()

Makefile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SHELL := /usr/bin/env bash
1212

1313
DEVICE ?= tanmatsu # Default target device
1414
BUILD ?= build/$(DEVICE)
15+
FAT ?= 1
1516

1617
export IDF_TOOLS_PATH
1718
export IDF_GITHUB_ASSETS
@@ -93,7 +94,7 @@ checkbuildenv:
9394

9495
.PHONY: build
9596
build: icons checkbuildenv submodules
96-
source "$(IDF_PATH)/export.sh" >/dev/null && idf.py -B $(BUILD) build -DDEVICE=$(DEVICE)
97+
source "$(IDF_PATH)/export.sh" >/dev/null && idf.py -B $(BUILD) build -DDEVICE=$(DEVICE) -DFAT=$(FAT)
9798

9899
# Hardware
99100

@@ -132,11 +133,19 @@ monitor:
132133

133134
.PHONY: openocd
134135
openocd:
135-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) openocd
136+
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) openocd
136137

137138
.PHONY: gdb
138139
gdb:
139-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) gdb
140+
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdb
141+
142+
.PHONY: gdbgui
143+
gdbgui:
144+
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdbgui
145+
146+
.PHONY: gdbtui
147+
gdbtui:
148+
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdbtui
140149

141150
# Tools
142151

@@ -197,20 +206,3 @@ buildall:
197206
flashall:
198207
$(MAKE) flash DEVICE=tanmatsu PORT=/dev/ttyACM0
199208
$(MAKE) flash DEVICE=mch2022 PORT=/dev/ttyACM2
200-
201-
202-
# Debugging
203-
.PHONY: openocd
204-
openocd:
205-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) openocd
206-
207-
.PHONY: gdb
208-
gdb:
209-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdb
210-
.PHONY: gdbgui
211-
212-
gdbgui:
213-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdbgui
214-
215-
gdbtui:
216-
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) -DDEVICE=$(DEVICE) gdbtui

components/gui/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ idf_component_register(
22
SRCS
33
gui_menu.c
44
gui_menu_render.c
5-
gui_footer.c
5+
gui_element_header.c
6+
gui_element_footer.c
7+
gui_element_icontext.c
68
gui_osk.c
79
gui_osk_edit.c
810
gui_edit.c
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "gui_element_footer.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
#include "gui_element_icontext.h"
6+
#include "pax_gfx.h"
7+
8+
void gui_footer_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count) {
10+
gui_element_style_t* style = &theme->footer;
11+
int buffer_width = pax_buf_get_width(pax_buffer);
12+
int buffer_height = pax_buf_get_height(pax_buffer);
13+
int box_height = style->height + (style->vertical_margin * 2);
14+
15+
pax_draw_line(pax_buffer, theme->palette.color_foreground, style->horizontal_margin, buffer_height - box_height,
16+
buffer_width - style->horizontal_margin, buffer_height - box_height);
17+
18+
int x = style->horizontal_margin + style->horizontal_padding;
19+
for (size_t i = 0; i < left_count; i++) {
20+
x += gui_icontext_draw(pax_buffer, theme, x, buffer_height - box_height, &left[i], style->horizontal_padding,
21+
box_height);
22+
}
23+
24+
x = buffer_width - style->horizontal_margin;
25+
for (size_t i = 0; i < right_count; i++) {
26+
x -= gui_icontext_width(theme, buffer_width, buffer_height, &right[i], style->horizontal_padding);
27+
gui_icontext_draw(pax_buffer, theme, x - style->horizontal_padding, buffer_height - box_height, &right[i],
28+
style->horizontal_padding, box_height);
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "gui_element_header.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
#include "gui_element_icontext.h"
6+
#include "pax_gfx.h"
7+
8+
void gui_header_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count) {
10+
gui_element_style_t* style = &theme->header;
11+
12+
int buffer_width = pax_buf_get_width(pax_buffer);
13+
int box_height = style->height + (style->vertical_margin * 2);
14+
15+
pax_draw_line(pax_buffer, theme->palette.color_foreground, style->horizontal_margin, box_height,
16+
buffer_width - style->horizontal_margin, box_height);
17+
18+
int x = style->horizontal_margin + style->horizontal_padding;
19+
for (size_t i = 0; i < left_count; i++) {
20+
x += gui_icontext_draw(pax_buffer, theme, x, 0, &left[i], style->horizontal_padding, box_height);
21+
}
22+
23+
x = buffer_width - style->horizontal_margin;
24+
for (size_t i = 0; i < right_count; i++) {
25+
x -= gui_icontext_width(theme, buffer_width, 0, &right[i], style->horizontal_padding);
26+
gui_icontext_draw(pax_buffer, theme, x - style->horizontal_padding, 0, &right[i], style->horizontal_padding,
27+
box_height);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "gui_element_icontext.h"
2+
#include <stddef.h>
3+
#include "gui_style.h"
4+
#include "pax_gfx.h"
5+
#include "pax_types.h"
6+
7+
float gui_icontext_width(gui_theme_t* theme, int x, int y, gui_element_icontext_t* content, float padding) {
8+
float icon_width = 0;
9+
if (content->icon) {
10+
icon_width = pax_buf_get_width(content->icon);
11+
}
12+
pax_vec2f text_size = pax_text_size(theme->footer.text_font, theme->footer.text_height, content->text);
13+
return icon_width + padding + text_size.x;
14+
}
15+
16+
float gui_icontext_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, int x, int y, gui_element_icontext_t* content,
17+
float padding, int box_height) {
18+
float icon_width = 0;
19+
if (content->icon) {
20+
icon_width = pax_buf_get_width(content->icon);
21+
float icon_height = pax_buf_get_height(content->icon);
22+
pax_draw_image(pax_buffer, content->icon, x, y + (box_height - icon_height) / 2);
23+
}
24+
pax_draw_text(pax_buffer, theme->palette.color_foreground, theme->footer.text_font, theme->footer.text_height,
25+
x + icon_width + padding, y + ((float)(box_height - theme->footer.text_height)) / 2.0f,
26+
content->text);
27+
pax_vec2f text_size = pax_text_size(theme->footer.text_font, theme->footer.text_height, content->text);
28+
return icon_width + padding + text_size.x;
29+
}

components/gui/gui_footer.c

Lines changed: 0 additions & 82 deletions
This file was deleted.

components/gui/gui_osk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include <malloc.h>
2727
#include <string.h>
2828
#include "esp_timer.h"
29+
#include "pax_fonts.h"
30+
#include "pax_gfx.h"
31+
#include "pax_shapes.h"
2932

3033
// Initialise the context with default settings.
3134
void gui_osk_init(pax_buf_t* buf, gui_osk_ctx_t* ctx, size_t buffer_cap) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include "gui_element_icontext.h"
5+
#include "gui_style.h"
6+
#include "pax_types.h"
7+
8+
void gui_footer_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include "gui_element_icontext.h"
5+
#include "gui_style.h"
6+
#include "pax_types.h"
7+
8+
void gui_header_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count);

0 commit comments

Comments
 (0)