Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 89-apps-should-be-able-to-specify-if-they-want-wifi-to-be-disabled-when-entering-them
  • 9Rmain
  • allow-reloading-sunmenu
  • always-have-a-wifi-instance
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • app_text_viewer
  • audio_input
  • audio_io
  • blm_dev_chan
  • ch3/bl00mbox_docs
  • ci-1690580595
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dx/dldldld
  • dx/fb-save-restore
  • dx/hint-hint
  • dx/jacksense-headset-mic-only
  • events
  • fil3s-limit-filesize
  • fil3s-media
  • fpletz/flake
  • gr33nhouse-improvements
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • led_fix_fix
  • main
  • main+schneider
  • media_has_video_has_audio
  • micropython_api
  • mixer2
  • moon2_demo_temp
  • moon2_migrate_apps
  • more-accurate-battery
  • pippin/ctx_sprite_sheet_support
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/more-accurate-battery
  • pippin/tcp_redirect_hack
  • pippin/tune_ctx_config_update_from_upstream
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • py_only_update_fps_overlay_when_changing
  • q3k/doom-poc
  • q3k/render-to-texture
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • release/1.2.0
  • release/1.3.0
  • release/1.4.0
  • restore_blit
  • return_of_melodic_demo
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • sector_size_512
  • shoegaze-fps
  • smaller_gradient_lut
  • store_delta_ms_and_ins_as_class_members
  • task_cleanup
  • uctx-wip
  • w1f1-in-sim
  • widgets_draw
  • wifi-json-error-handling
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
  • v1.4.0
94 results

Target

Select target project
  • flow3r/flow3r-firmware
  • Vespasian/flow3r-firmware
  • alxndr42/flow3r-firmware
  • pl/flow3r-firmware
  • Kari/flow3r-firmware
  • raimue/flow3r-firmware
  • grandchild/flow3r-firmware
  • mu5tach3/flow3r-firmware
  • Nervengift/flow3r-firmware
  • arachnist/flow3r-firmware
  • TheNewCivilian/flow3r-firmware
  • alibi/flow3r-firmware
  • manuel_v/flow3r-firmware
  • xeniter/flow3r-firmware
  • maxbachmann/flow3r-firmware
  • yGifoom/flow3r-firmware
  • istobic/flow3r-firmware
  • EiNSTeiN_/flow3r-firmware
  • gnudalf/flow3r-firmware
  • 999eagle/flow3r-firmware
  • toerb/flow3r-firmware
  • pandark/flow3r-firmware
  • teal/flow3r-firmware
  • x42/flow3r-firmware
  • alufers/flow3r-firmware
  • dos/flow3r-firmware
  • yrlf/flow3r-firmware
  • LuKaRo/flow3r-firmware
  • ThomasElRubio/flow3r-firmware
  • ai/flow3r-firmware
  • T_X/flow3r-firmware
  • highTower/flow3r-firmware
  • beanieboi/flow3r-firmware
  • Woazboat/flow3r-firmware
  • gooniesbro/flow3r-firmware
  • marvino/flow3r-firmware
  • kressnerd/flow3r-firmware
  • quazgar/flow3r-firmware
  • aoid/flow3r-firmware
  • jkj/flow3r-firmware
  • naomi/flow3r-firmware
41 results
Select Git revision
  • 9Rmain
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • audio_input
  • audio_io
  • bl00mbox
  • bl00mbox_old
  • captouch-threshold
  • ch3/bl00mbox_docs
  • ci-1690580595
  • compressor
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dos
  • dos-main-patch-50543
  • events
  • fm_fix
  • fm_fix2
  • fpletz/flake
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • json-error
  • main
  • main+schneider
  • media-buf
  • micropython_api
  • moon2_applications
  • moon2_demo_temp
  • moon2_gay_drums
  • passthrough
  • phhw
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/media_framework
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • q3k/doom-poc
  • rahix/big-flow3r
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • simtest
  • slewtest
  • t
  • test
  • test2
  • uctx-wip
  • view-think
  • vm-pending
  • vsync
  • wave
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
83 results
Show changes
Showing
with 0 additions and 2712 deletions
This diff is collapsed.
This diff is collapsed.
#include "badge23/display.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "esp_log.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "../../usermodule/uctx/uctx/ctx.h"
#include "flow3r_bsp.h"
#include "st3m_gfx.h"
typedef struct {
Ctx *ctx;
st3m_framebuffer_desc_t *desc;
} ctx_target_t;
static void new_ctx_target(ctx_target_t *target, st3m_framebuffer_desc_t *desc) {
Ctx *ctx = ctx_new_for_framebuffer(
desc->buffer,
FLOW3R_BSP_DISPLAY_WIDTH,
FLOW3R_BSP_DISPLAY_HEIGHT,
FLOW3R_BSP_DISPLAY_WIDTH * 2,
CTX_FORMAT_RGB565_BYTESWAPPED
);
assert(ctx != NULL);
int32_t offset_x = FLOW3R_BSP_DISPLAY_WIDTH / 2;
int32_t offset_y = FLOW3R_BSP_DISPLAY_HEIGHT / 2;
// rotate by 180 deg and translate x and y by 120 px to have (0,0) at the center of the screen
ctx_apply_transform(ctx,-1,0,offset_x,0,-1,offset_y,0,0,1);
target->ctx = ctx;
target->desc = desc;
}
static ctx_target_t targets[ST3M_GFX_NBUFFERS];
static void display_loading_splash(ctx_target_t *target) {
ctx_rgb(target->ctx, 0.157, 0.129, 0.167);
ctx_rectangle(target->ctx, -120, -120, 240, 240);
ctx_fill(target->ctx);
ctx_move_to(target->ctx, 0, 0);
ctx_rgb(target->ctx, 0.9, 0.9, 0.9);
ctx_text_align(target->ctx, CTX_TEXT_ALIGN_CENTER);
ctx_text_baseline(target->ctx, CTX_TEXT_BASELINE_ALPHABETIC);
ctx_text(target->ctx, "Loading...");
}
static ctx_target_t *next_target(void) {
st3m_framebuffer_desc_t *desc = st3m_gfx_framebuffer_get(portMAX_DELAY);
if (targets[desc->num].ctx == NULL) {
new_ctx_target(&targets[desc->num], desc);
}
return &targets[desc->num];
}
static bool initialized = false;
static ctx_target_t *sync_target = NULL;
void display_init() {
// HACK: needed until we have new async gfx api.
assert(ST3M_GFX_NBUFFERS == 1);
st3m_gfx_init();
for (int i = 0; i < ST3M_GFX_NBUFFERS; i++) {
targets[i].ctx = NULL;
targets[i].desc = NULL;
}
ctx_target_t *tgt = next_target();
display_loading_splash(tgt);
st3m_gfx_framebuffer_queue(tgt->desc);
sync_target = next_target();
flow3r_bsp_display_set_backlight(100);
initialized = true;
}
void display_update(){
if (!initialized) {
return;
}
st3m_gfx_framebuffer_queue(sync_target->desc);
ctx_target_t *tgt = next_target();
assert(tgt == sync_target);
}
void display_set_backlight(uint8_t percent) {
if (!initialized) {
return;
}
flow3r_bsp_display_set_backlight(percent);
}
Ctx *display_global_ctx(void) {
if (!initialized) {
return NULL;
}
return sync_target->ctx;
}
\ No newline at end of file
#include "badge23/captouch.h"
#include "badge23/audio.h"
#include "badge23/leds.h"
#include "badge23/display.h"
#include "badge23/spio.h"
#include "badge23/lock.h"
#include "flow3r_bsp.h"
#include "esp_log.h"
#include "driver/i2c.h"
#include "driver/spi_master.h"
#include <freertos/timers.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdint.h>
static const char *TAG = "espan";
#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#if defined(CONFIG_BADGE23_HW_GEN_P3) || defined(CONFIG_BADGE23_HW_GEN_P4) || defined(CONFIG_BADGE23_HW_GEN_P6)
#define CONFIG_I2C_MASTER_SDA 2
#define CONFIG_I2C_MASTER_SCL 1
#elif defined(CONFIG_BADGE23_HW_GEN_P1)
#define CONFIG_I2C_MASTER_SDA 10
#define CONFIG_I2C_MASTER_SCL 9
#else
#error "i2c not implemented for this badge generation"
#endif
static QueueHandle_t i2c_queue = NULL;
static QueueHandle_t slow_system_status_queue = NULL;
static uint8_t dummy_data;
static esp_err_t i2c_master_init(void)
{
int i2c_master_port = I2C_MASTER_NUM;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = CONFIG_I2C_MASTER_SDA,
.scl_io_num = CONFIG_I2C_MASTER_SCL,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_param_config(i2c_master_port, &conf);
return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
}
#define CAPTOUCH_POLLING_PERIOD 10
#define SLOW_SYSTEM_STATUS_PERIOD 100
static uint8_t hw_init_done = 0;
void i2c_timer(TimerHandle_t data){
xQueueSend(i2c_queue, &dummy_data, 0);
}
void i2c_task(void * data){
while(1){
xQueueReceive(i2c_queue, &dummy_data, portMAX_DELAY);
captouch_read_cycle();
update_button_state();
}
}
void slow_system_status_timer(TimerHandle_t data){
xQueueSend(slow_system_status_queue, &dummy_data, 0);
}
void slow_system_status_task(void * data){
while(1){
xQueueReceive(slow_system_status_queue, &dummy_data, portMAX_DELAY);
//read out stuff like jack detection, battery status, usb connection etc.
audio_update_jacksense();
leds_update_hardware();
}
}
void locks_init(){
mutex_i2c = xSemaphoreCreateMutex();
mutex_LED = xSemaphoreCreateMutex();
}
void os_app_main(void)
{
// Initialize display first as that gives us a nice splash screen.
display_init();
locks_init();
ESP_LOGI(TAG, "Starting on %s...", flow3r_bsp_hw_name);
ESP_ERROR_CHECK(i2c_master_init());
ESP_LOGI(TAG, "I2C initialized successfully");
audio_init();
leds_init();
init_buttons();
captouch_init();
spio_badge_link_disable(255);
captouch_force_calibration();
i2c_queue = xQueueCreate(1,1);
TaskHandle_t i2c_task_handle;
xTaskCreatePinnedToCore(&i2c_task, "I2C task", 4096, NULL, configMAX_PRIORITIES-1, &i2c_task_handle, 0);
TimerHandle_t i2c_timer_handle = xTimerCreate("I2C timer", pdMS_TO_TICKS(CAPTOUCH_POLLING_PERIOD), pdTRUE, (void *) 0, *i2c_timer);
if( xTimerStart(i2c_timer_handle, 0 ) != pdPASS) ESP_LOGI(TAG, "I2C timer initialization failed");
slow_system_status_queue = xQueueCreate(1,1);
TaskHandle_t slow_system_status_task_handle;
xTaskCreatePinnedToCore(&slow_system_status_task, "slow system status task", 4096, NULL, configMAX_PRIORITIES-2, &slow_system_status_task_handle, 0);
TimerHandle_t slow_system_status_timer_handle = xTimerCreate("slow system status timer", pdMS_TO_TICKS(SLOW_SYSTEM_STATUS_PERIOD), pdTRUE, (void *) 0, *slow_system_status_timer);
if( xTimerStart(slow_system_status_timer_handle, 0 ) != pdPASS) ESP_LOGI(TAG, "I2C task initialization failed");
hw_init_done = 1;
}
uint8_t hardware_is_initialized(){
return hw_init_done;
}
#ifndef DEF_apa102LEDStrip
#define DEF_apa102LEDStrip
struct apa102LEDStrip
{
unsigned char *LEDs;
short int _frameLength;
short int _endFrameLength;
short int _numLEDs;
unsigned char _bytesPerLED;
short int _counter;
unsigned char _globalBrightness;
};
void initLEDs(struct apa102LEDStrip *ledObject, short int numLEDs, unsigned char bytesPerLED, unsigned char globalBrightness);
void setPixel(struct apa102LEDStrip *ledObject, short int pixelIndex, unsigned char *pixelColour);
void getPixel(struct apa102LEDStrip *ledObject, short int pixelIndex, unsigned char *pixelColour);
#endif
This diff is collapsed.
#pragma once
#include <stdint.h>
/* GENERAL INFORMATION
*
* petal index: 0 is the top petal above the USB-C jack, increases ccw so that
* bottom petals are uneven and top petals even.
* TODO: LEDs are indexed differently, this should be harmonized
* in the impending API refactor.
*
* captouch data: full uint16_t range per stage, higher values indicate touch.
* pad index: defined in captouch.c
*
*
* IOU: the internals are still subject to major restructuring and are not
* documented as of yet. will do once the data structures actually make sense
* and are not duct tape upon duct tape.
*/
/* polls data from both captouch chips and processes it, either by updating
* the captouch data exposed to the user or running a calibration cycle.
*
* the captouch chips has updated their registers every 9.2ms, so the fn
* should be called every 10ms or so.
*
* this will be replaced someday by an interrupt event triggered system,
* but this would ideally already implement configuration switching to
* optimize latency by grouping pads and to expose the unused pad which
* is a nontrivial task for another day.
*/
void captouch_read_cycle(void);
/* the captouch chip can generate an "afe" offset in the analog domain before
* the ADC to optimize the readout range. according to the datasheet this should
* be in the middle of the 16bit delta sigma ADC range (without much reasoning
* supplied), however we found that having a higher range is beneficial.
*
* the calibration cycle is optimizing the afe coefficients so that the output of
* the "untouched" pads is close to the target set with this with this function/
*
* default target: 6000, manufacturer recommendation: 32676
*/
void captouch_set_calibration_afe_target(uint16_t target);
/* starts a a calibration cycle which is intended to run when the captouch
* pads are not being touched. the cycle consists of two parts:
*
* 1) optimize the afe coefficients (see captouch_set_calibration_afe_target)
*
* 2) with the new afe coefficients applied, average the readings in the untouched
* state into a software calibration list which is normally subtracted from the
* captouch outputs. this makes up for the limited resolution of the of the afe
* coefficient calibration.
*/
void captouch_force_calibration();
/* indicates if a calibration cycle is currently active. the readings for
* captouch_read_cycle and captouch_get_petal_* during a calibration cycle.
*
* 1: calibration cycle active
* 0: calibration cycle inactive
*/
uint8_t captouch_calibration_active();
/* returns uint16_t which encodes each petal "touched" state as the bit
* corresponding to the petal index. "touched" is determined by checking if
* any of the pads belonging to the petal read a value higher than their
* calibration value plus their threshold (see captouch_set_petal_pad_threshold)
*/
uint16_t read_captouch(void);
/* sets threshold for a petal pad above which read_captouch considers a pad as
* touched.
*
* petal: petal index
* pad: pad index
* thres: threshold value
*/
void captouch_set_petal_pad_threshold(uint8_t petal, uint8_t pad, uint16_t thres);
/* returns last read captouch value from a petal pad without subtracting its
* calibration reference. typically only needed for debugging.
*
* petal: petal index
* pad: pad index
*/
uint16_t captouch_get_petal_pad_raw(uint8_t petal, uint8_t pad);
/* returns calibration reference for a petal pad.
*
* petal: petal index
* pad: pad index
*/
uint16_t captouch_get_petal_pad_calib_ref(uint8_t petal, uint8_t pad);
/* returns calibrated value from petal. clamps below 0.
*
* petal: petal index
* pad: pad index
*/
uint16_t captouch_get_petal_pad(uint8_t petal, uint8_t pad);
/* estimates the azimuthal finger position on a petal in arbitrary units.
* returns 0 if hardware doesn't support this.
*
* petal: petal index
* pad: pad index
*/
int32_t captouch_get_petal_phi(uint8_t petal);
/* estimates the radial finger position on a petal in arbitrary units.
* returns 0 if hardware doesn't support this.
*
* petal: petal index
* pad: pad index
*/
int32_t captouch_get_petal_rad(uint8_t petal);
/* configures the captouch chips, prefills internal structs etc.
*/
void captouch_init(void);
/* TODO: didn't look into what it does, never used it, just copied it from
* the hardware verification firmware along with the rest. didn't break it
* _intentionally_ but never tested it either.
*/
void captouch_print_debug_info(void);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.