Skip to content

Commit

Permalink
feat: implement light.max_pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jan 11, 2021
1 parent c686b66 commit 592af98
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 11 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ BASE_TARGET ?= $(TARGET)
PROFILES = $(patsubst targets/$(TARGET)/profile/%.c,%,$(wildcard targets/$(TARGET)/profile/*.c))

ifeq ($(BL),)
DEFINES += -DDEVICE_DMESG_BUFFER_SIZE=1024
C_SRC += $(wildcard jacdac-c/source/*.c)
C_SRC += $(wildcard jacdac-c/services/*.c)
C_SRC += $(wildcard jacdac-c/drivers/*.c)
Expand Down
2 changes: 1 addition & 1 deletion src/blhw.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "jd_config.h"
#include <stdint.h>
#include <stdbool.h>
#include "hwconfig.h"
#include "services/interfaces/jd_pins.h"
#include "jd_config.h"

#define RAM_FUNC __attribute__((noinline, long_call, section(".data")))

Expand Down
4 changes: 4 additions & 0 deletions src/dmesg.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#define NOLOG(...) ((void)0)

#ifndef DEVICE_DMESG_BUFFER_SIZE
#define DEVICE_DMESG_BUFFER_SIZE 1024
#endif

#if DEVICE_DMESG_BUFFER_SIZE > 0

#if DEVICE_DMESG_BUFFER_SIZE < 256
Expand Down
2 changes: 1 addition & 1 deletion src/jd_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#define JD_CONFIG_TEMPERATURE 1

#include "dmesg.h"
#include "board.h"
#include "dmesg.h"

#define JD_LOG DMESG

Expand Down
2 changes: 1 addition & 1 deletion src/jdprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <string.h>
#include <stdbool.h>

#include "jd_services.h"
#include "dmesg.h"
#include "pinnames.h"
#include "jd_services.h"
#include "interfaces/jd_app.h"
#include "blhw.h"

Expand Down
4 changes: 3 additions & 1 deletion src/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>

#include "jd_protocol.h"

#include "dmesg.h"
#include "pinnames.h"

#include "jd_protocol.h"
#include "services/interfaces/jd_oled.h"
#include "services/interfaces/jd_hw_pwr.h"

Expand Down
15 changes: 10 additions & 5 deletions stm32/dspi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jdstm.h"

#include "services/interfaces/jd_pixel.h"

#define CHUNK_LEN 3 * 4 * 2
#define PX_SCRATCH_LEN (6 * CHUNK_LEN) // 144 bytes

Expand Down Expand Up @@ -309,11 +311,6 @@ static void px_dma(void) {
}

void px_tx(const void *data, uint32_t numbytes, uint8_t intensity, cb_t doneHandler) {
if (px_state.pxscratch == NULL) {
px_state.pxscratch = jd_alloc(PX_SCRATCH_LEN);
dma_handler = px_dma;
}

px_state.pxdata = data;
px_state.pxdata_len = numbytes;
px_state.pxdata_ptr = 0;
Expand Down Expand Up @@ -362,6 +359,13 @@ void DMA_Handler(void) {
// 0 - 0.40us hi 0.85us low
// 1 - 0.80us hi 0.45us low

void px_alloc() {
if (px_state.pxscratch == NULL) {
px_state.pxscratch = jd_alloc(PX_SCRATCH_LEN);
dma_handler = px_dma;
}
}

void px_init(int light_type) {
SPI_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
Expand Down Expand Up @@ -408,6 +412,7 @@ void px_init(int light_type) {
NVIC_EnableIRQ(IRQn);

init_lookup();
px_alloc();
}

#endif
4 changes: 4 additions & 0 deletions targets/jm-v2.0/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
#define USART_IDX 1

#define SND_OFF 0

#ifndef BL
#define DEVICE_DMESG_BUFFER_SIZE 832
#endif
4 changes: 4 additions & 0 deletions targets/jm-v2.1/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
#define PIN_PWR PA_10
#define PIN_AMOSI PA_7
#define PIN_ASCK PA_5

#ifndef BL
#define DEVICE_DMESG_BUFFER_SIZE 832
#endif

0 comments on commit 592af98

Please sign in to comment.