Merge pull request #5 from badgeteam/update-components
Updated components
This commit is contained in:
commit
db2b6a666e
4 changed files with 93 additions and 28 deletions
9
Makefile
9
Makefile
|
@ -4,9 +4,9 @@ IDF_PATH ?= $(shell pwd)/esp-idf
|
|||
IDF_EXPORT_QUIET ?= 0
|
||||
SHELL := /usr/bin/env bash
|
||||
|
||||
.PHONY: prepare clean build flash erase monitor menuconfig
|
||||
.PHONY: prepare clean build flash monitor menuconfig
|
||||
|
||||
all: prepare build
|
||||
all: prepare build install
|
||||
|
||||
prepare:
|
||||
git submodule update --init --recursive
|
||||
|
@ -18,12 +18,9 @@ clean:
|
|||
build:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py build
|
||||
|
||||
install: prepare build
|
||||
install: build
|
||||
python3 tools/webusb_push.py "Template App" build/main.bin --run
|
||||
|
||||
erase:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py erase-flash -p $(PORT)
|
||||
|
||||
monitor:
|
||||
source "$(IDF_PATH)/export.sh" && idf.py monitor -p $(PORT)
|
||||
|
||||
|
|
33
README.md
33
README.md
|
@ -25,10 +25,41 @@ following table for details.
|
|||
| components/spi-ili9341 | MIT | Nicolai Electronics |
|
||||
| components/ws2812 | Unlicense / Public domain | None |
|
||||
|
||||
|
||||
Source the `update_components.sh` to update all the submodules to their
|
||||
corresponding tips.
|
||||
|
||||
## How to make
|
||||
```sh
|
||||
git clone --recursive https://github.com/badgeteam/mch2022-template-app
|
||||
cd mch2022-template-app
|
||||
make prepare
|
||||
make
|
||||
```
|
||||
|
||||
The default target of the Makefile (the one executed if you just run `make`) installs the proper ESP-IDF version and all other dependencies, then builds the project and tries to install it on an attached Badge. Because this process checks all the dependencies for updates, this can become tedious during development, so you'll probably want to execute specific targets:
|
||||
|
||||
- prepare : this is (one of) the targets executed in the default task and the one that, technically, only needs to run once to install dependencies
|
||||
- clean : clean the build environment. This does NOT clean up installed dependencies.
|
||||
- build : well ... build. Compiles you sources and assembles a binary to install.
|
||||
- install : This install the binary that was build, you can only call `install`, it depends on `build`. *Note* installation is not and SHOULD NOT be performed with the typical `idf.py flash` call, see the note below for details.
|
||||
- monitor : start the serial monitor to examine log output
|
||||
- menuconfig : The IDF build system has a fairly elaborate configuration system that can be accessed via `menuconfig`. You'll know if you need it. Or try it out to explore.
|
||||
|
||||
|
||||
### Note: Why not to use `idf.py flash` to install my native app.
|
||||
|
||||
If you have previously used the IDF, you may have noticed that we don’t use
|
||||
`idf.py flash` to install the app on the Badge. (And if you haven’t, you can
|
||||
safely skip this section. :)
|
||||
|
||||
The `idf.py flash` command assumes that the binary to flash is the main (and
|
||||
only) application for the device. This is not the case for the Badge, though.
|
||||
The main application is the launcher app, i.e. the app with the menu that
|
||||
starts by default. The `make install` target of the Makefile copies our newly
|
||||
created app into the
|
||||
[appfs](https://github.com/badgeteam/esp32-component-appfThe Makefile cs)
|
||||
instead of overwriting the launcher. Once copied to the appfs, the launcher can
|
||||
find your app and it should appear in the apps menu.
|
||||
|
||||
Obviously you _can_ use idf.py flash but you’ll delete the launcher app and would
|
||||
need to reinstall it later.
|
||||
|
|
59
main/main.c
59
main/main.c
|
@ -5,14 +5,18 @@
|
|||
* CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
// This file contains a simple Hello World app which you can base you own
|
||||
// native Badge apps on.
|
||||
|
||||
#include "main.h"
|
||||
|
||||
static pax_buf_t buf;
|
||||
xQueueHandle buttonQueue;
|
||||
|
||||
#include <esp_log.h>
|
||||
static const char *TAG = "mch2022-demo-app";
|
||||
|
||||
// Updates the screen with the last drawing.
|
||||
// Updates the screen with the latest buffer.
|
||||
void disp_flush() {
|
||||
ili9341_write(get_ili9341(), buf.buf);
|
||||
}
|
||||
|
@ -24,20 +28,26 @@ void exit_to_launcher() {
|
|||
}
|
||||
|
||||
void app_main() {
|
||||
// Init the screen, the I2C and the SPI busses.
|
||||
|
||||
|
||||
ESP_LOGI(TAG, "Welcome to the template app!");
|
||||
|
||||
// Initialize the screen, the I2C and the SPI busses.
|
||||
bsp_init();
|
||||
// Init the RP2040 (responsible for buttons among other important things).
|
||||
|
||||
// Initialize the RP2040 (responsible for buttons, etc).
|
||||
bsp_rp2040_init();
|
||||
// This queue is used to await button presses.
|
||||
|
||||
// This queue is used to receive button presses.
|
||||
buttonQueue = get_rp2040()->queue;
|
||||
|
||||
// Init graphics for the screen.
|
||||
// Initialize graphics for the screen.
|
||||
pax_buf_init(&buf, NULL, 320, 240, PAX_BUF_16_565RGB);
|
||||
|
||||
// Init NVS.
|
||||
// Initialize NVS.
|
||||
nvs_flash_init();
|
||||
|
||||
// Init (but not connect to) WiFi.
|
||||
// Initialize WiFi. This doesn't connect to Wifi yet.
|
||||
wifi_init();
|
||||
|
||||
while (1) {
|
||||
|
@ -45,37 +55,44 @@ void app_main() {
|
|||
int hue = esp_random() & 255;
|
||||
pax_col_t col = pax_col_hsv(hue, 255 /*saturation*/, 255 /*brighness*/);
|
||||
|
||||
// Show some random color hello world.
|
||||
// Draw the background with aforementioned random color.
|
||||
// Greet the World in front of a random background color!
|
||||
// Fill the background with the random color.
|
||||
pax_background(&buf, col);
|
||||
|
||||
// This text is shown on screen.
|
||||
char *text = "Hello, World!";
|
||||
// Pick the font to draw in (this is the only one that looks nice this big).
|
||||
char *text = "Hello, MCH2022!";
|
||||
|
||||
// Pick the font (Saira is the only one that looks nice in this size).
|
||||
const pax_font_t *font = pax_font_saira_condensed;
|
||||
// Determine how large the text is so it can be centered.
|
||||
|
||||
// Determine how the text dimensions so we can display it centered on
|
||||
// screen.
|
||||
pax_vec1_t dims = pax_text_size(font, font->default_size, text);
|
||||
// Use info to draw the centered text.
|
||||
|
||||
// Draw the centered text.
|
||||
pax_draw_text(
|
||||
// Buffer to draw to.
|
||||
&buf, 0xff000000,
|
||||
// Font and size to use.
|
||||
font, font->default_size,
|
||||
&buf, // Buffer to draw to.
|
||||
0xff000000, // color
|
||||
font, font->default_size, // Font and size to use.
|
||||
// Position (top left corner) of the app.
|
||||
(buf.width - dims.x) / 2.0,
|
||||
(buf.height - dims.y) / 2.0,
|
||||
// The text to be shown.
|
||||
// The text to be rendered.
|
||||
text
|
||||
);
|
||||
|
||||
// Draws the entire graphics buffer to the screen.
|
||||
disp_flush();
|
||||
|
||||
// Await any button press and do another cycle.
|
||||
// Wait for button presses and do another cycle.
|
||||
|
||||
// Structure used to receive data.
|
||||
rp2040_input_message_t message;
|
||||
// Await forever (because of portMAX_DELAY), a button press.
|
||||
|
||||
// Wait forever for a button press (because of portMAX_DELAY)
|
||||
xQueueReceive(buttonQueue, &message, portMAX_DELAY);
|
||||
|
||||
// Is the home button currently pressed?
|
||||
// Which button is currently pressed?
|
||||
if (message.input == RP2040_INPUT_BUTTON_HOME && message.state) {
|
||||
// If home is pressed, exit to launcher.
|
||||
exit_to_launcher();
|
||||
|
|
20
update_components.sh
Normal file
20
update_components.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
BASE=`pwd`
|
||||
for component in appfs bus-i2c i2c-bno055 mch2022-bsp mch2022-rp2040 sdcard spi-ice40 spi-ili9341 ws2812; do
|
||||
cd $BASE/components/$component
|
||||
git checkout master
|
||||
git pull
|
||||
cd $BASE
|
||||
done
|
||||
|
||||
for component in i2c-bme680 pax-codecs pax-graphics pax-keyboard; do
|
||||
cd $BASE/components/$component
|
||||
git checkout main
|
||||
git pull
|
||||
cd $BASE
|
||||
done
|
||||
|
||||
cd $BASE/tools
|
||||
git checkout master
|
||||
git pull
|
||||
cd $BASE
|
Loading…
Reference in a new issue