diff --git a/firmware/Makefile b/firmware/Makefile index 5bce1a9f..0def504c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -65,7 +65,7 @@ modules: $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin $(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin - $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin + $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin $(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf $(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin diff --git a/firmware/application/bulb_ignore_bmp.hpp b/firmware/application/bulb_ignore_bmp.hpp new file mode 100644 index 00000000..35ac9ce7 --- /dev/null +++ b/firmware/application/bulb_ignore_bmp.hpp @@ -0,0 +1,47 @@ +const unsigned char bulb_ignore_bmp[] = { + 0x42, 0x4d, 0xc6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0x00, + 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x70, 0x01, + 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x19, 0x19, 0x19, 0x00, 0x29, 0x2e, 0x21, 0x00, 0x1b, 0x1b, + 0x66, 0x00, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x55, 0x55, + 0x55, 0x00, 0x6c, 0x6c, 0x6c, 0x00, 0x95, 0x95, 0x95, 0x00, 0x0a, 0x44, + 0x02, 0x77, 0x02, 0x77, 0x0a, 0x44, 0x00, 0x00, 0x00, 0x18, 0x42, 0x24, + 0x44, 0x44, 0x47, 0x30, 0x03, 0x74, 0x44, 0x44, 0x42, 0x24, 0x00, 0x00, + 0x00, 0x18, 0x42, 0x22, 0x44, 0x44, 0x73, 0x66, 0x55, 0x37, 0x44, 0x44, + 0x22, 0x24, 0x00, 0x00, 0x00, 0x18, 0x44, 0x22, 0x24, 0x44, 0x76, 0x33, + 0x33, 0x57, 0x44, 0x42, 0x22, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x42, + 0x22, 0x44, 0x73, 0x66, 0x55, 0x37, 0x44, 0x22, 0x24, 0x44, 0x00, 0x00, + 0x00, 0x18, 0x44, 0x44, 0x22, 0x24, 0x76, 0x33, 0x33, 0x57, 0x42, 0x22, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, 0x42, 0x22, 0x73, 0x66, + 0x55, 0x37, 0x22, 0x24, 0x44, 0x44, 0x00, 0x00, 0x06, 0x44, 0x00, 0x0c, + 0x22, 0x26, 0x53, 0x35, 0x52, 0x22, 0x06, 0x44, 0x00, 0x00, 0x06, 0x44, + 0x00, 0x0c, 0x42, 0x22, 0x31, 0x13, 0x22, 0x24, 0x06, 0x44, 0x00, 0x00, + 0x06, 0x44, 0x00, 0x0c, 0x47, 0x22, 0x21, 0x12, 0x22, 0x74, 0x06, 0x44, + 0x00, 0x00, 0x06, 0x44, 0x00, 0x0c, 0x74, 0x42, 0x22, 0x22, 0x24, 0x47, + 0x06, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, 0x47, 0x44, 0x44, 0x22, + 0x22, 0x44, 0x44, 0x74, 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, + 0x47, 0x44, 0x64, 0x22, 0x22, 0x44, 0x44, 0x74, 0x44, 0x44, 0x00, 0x00, + 0x00, 0x18, 0x44, 0x44, 0x74, 0x44, 0x62, 0x22, 0x22, 0x24, 0x44, 0x47, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, 0x74, 0x46, 0x22, 0x24, + 0x42, 0x22, 0x44, 0x47, 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, + 0x74, 0x42, 0x22, 0x44, 0x44, 0x22, 0x24, 0x47, 0x44, 0x44, 0x00, 0x00, + 0x00, 0x18, 0x44, 0x44, 0x74, 0x22, 0x23, 0x44, 0x44, 0x32, 0x22, 0x47, + 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, 0x72, 0x22, 0x60, 0x44, + 0x44, 0x00, 0x22, 0x27, 0x44, 0x44, 0x00, 0x00, 0x00, 0x18, 0x44, 0x44, + 0x22, 0x24, 0x66, 0x00, 0x00, 0x44, 0x42, 0x22, 0x44, 0x44, 0x00, 0x00, + 0x00, 0x0a, 0x44, 0x42, 0x22, 0x44, 0x46, 0x00, 0x08, 0x44, 0x00, 0x06, + 0x22, 0x24, 0x44, 0x00, 0x00, 0x00, 0x00, 0x08, 0x44, 0x22, 0x24, 0x74, + 0x08, 0x44, 0x00, 0x08, 0x47, 0x42, 0x22, 0x44, 0x00, 0x00, 0x00, 0x08, + 0x42, 0x22, 0x44, 0x47, 0x08, 0x44, 0x00, 0x08, 0x74, 0x44, 0x22, 0x24, + 0x00, 0x00, 0x00, 0x18, 0x42, 0x24, 0x44, 0x44, 0x74, 0x44, 0x44, 0x47, + 0x44, 0x44, 0x42, 0x24, 0x00, 0x00, 0x08, 0x44, 0x00, 0x08, 0x47, 0x77, + 0x77, 0x74, 0x08, 0x44, 0x00, 0x01 +}; +const unsigned int bulb_ignore_bmp_len = 522; diff --git a/firmware/application/bulb_off_bmp.hpp b/firmware/application/bulb_off_bmp.hpp new file mode 100644 index 00000000..679f8a58 --- /dev/null +++ b/firmware/application/bulb_off_bmp.hpp @@ -0,0 +1,43 @@ +const unsigned char bulb_off_bmp[] = { + 0x42, 0x4d, 0x9a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x00, + 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x01, + 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x39, 0x39, 0x39, 0x00, 0xff, 0x00, 0xff, 0x00, 0x55, 0x5f, + 0x45, 0x00, 0x5b, 0x5b, 0x5b, 0x00, 0x7d, 0x7d, 0x7d, 0x00, 0x9d, 0x9d, + 0x9d, 0x00, 0xff, 0xff, 0xff, 0x00, 0x0a, 0x11, 0x02, 0x66, 0x02, 0x66, + 0x0a, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x16, 0x30, 0x03, 0x61, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x63, 0x55, 0x44, 0x36, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x65, 0x33, 0x33, 0x46, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x63, 0x55, 0x44, 0x36, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x65, 0x33, 0x33, 0x46, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x63, 0x55, 0x44, 0x36, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x65, 0x43, 0x34, 0x46, + 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, 0x00, 0x08, 0x63, 0x32, 0x23, 0x36, + 0x08, 0x11, 0x00, 0x00, 0x06, 0x11, 0x00, 0x0c, 0x16, 0x11, 0x22, 0x22, + 0x11, 0x61, 0x06, 0x11, 0x00, 0x00, 0x06, 0x11, 0x00, 0x0c, 0x61, 0x11, + 0x24, 0x22, 0x11, 0x16, 0x06, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, + 0x16, 0x11, 0x11, 0x24, 0x22, 0x11, 0x11, 0x61, 0x11, 0x11, 0x00, 0x00, + 0x00, 0x18, 0x11, 0x11, 0x16, 0x11, 0x51, 0x34, 0x43, 0x11, 0x11, 0x61, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x61, 0x11, 0x51, 0x31, + 0x13, 0x11, 0x11, 0x16, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, + 0x61, 0x15, 0x51, 0x31, 0x13, 0x11, 0x11, 0x16, 0x11, 0x11, 0x00, 0x00, + 0x00, 0x18, 0x11, 0x11, 0x61, 0x15, 0x53, 0x11, 0x11, 0x31, 0x11, 0x16, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x61, 0x15, 0x53, 0x11, + 0x11, 0x31, 0x11, 0x16, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, + 0x61, 0x11, 0x50, 0x11, 0x11, 0x00, 0x11, 0x16, 0x11, 0x11, 0x00, 0x00, + 0x00, 0x18, 0x11, 0x11, 0x16, 0x11, 0x55, 0x00, 0x00, 0x11, 0x11, 0x61, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x11, 0x11, 0x16, 0x11, 0x15, 0x00, + 0x08, 0x11, 0x00, 0x06, 0x61, 0x11, 0x11, 0x00, 0x00, 0x00, 0x06, 0x11, + 0x02, 0x61, 0x08, 0x11, 0x02, 0x16, 0x06, 0x11, 0x00, 0x00, 0x06, 0x11, + 0x02, 0x16, 0x08, 0x11, 0x02, 0x61, 0x06, 0x11, 0x00, 0x00, 0x08, 0x11, + 0x00, 0x08, 0x61, 0x11, 0x11, 0x16, 0x08, 0x11, 0x00, 0x00, 0x08, 0x11, + 0x00, 0x08, 0x16, 0x66, 0x66, 0x61, 0x08, 0x11, 0x00, 0x01 +}; +const unsigned int bulb_off_bmp_len = 478; diff --git a/firmware/application/bulb_on_bmp.hpp b/firmware/application/bulb_on_bmp.hpp new file mode 100644 index 00000000..72d99d01 --- /dev/null +++ b/firmware/application/bulb_on_bmp.hpp @@ -0,0 +1,46 @@ +const unsigned char bulb_on_bmp[] = { + 0x42, 0x4d, 0xba, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, + 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x01, + 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x09, 0x00, + 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x39, 0x39, 0x39, 0x00, 0xff, 0x00, 0xff, 0x00, 0x5b, 0x5b, + 0x5b, 0x00, 0x7d, 0x7d, 0x7d, 0x00, 0x90, 0xa0, 0x75, 0x00, 0x9d, 0x9d, + 0x9d, 0x00, 0x44, 0xe5, 0xff, 0x00, 0x85, 0xfe, 0xff, 0x00, 0xff, 0xff, + 0xff, 0x00, 0x0a, 0x11, 0x02, 0x88, 0x02, 0x88, 0x0a, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x18, 0x20, 0x02, 0x81, 0x08, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x82, 0x55, 0x33, 0x28, 0x08, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x85, 0x22, 0x22, 0x38, 0x08, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x82, 0x55, 0x33, 0x28, 0x08, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x85, 0x22, 0x22, 0x38, 0x08, 0x11, 0x00, 0x00, + 0x08, 0x11, 0x00, 0x08, 0x82, 0x55, 0x32, 0x28, 0x08, 0x11, 0x00, 0x00, + 0x00, 0x18, 0x11, 0x61, 0x11, 0x11, 0x85, 0x33, 0x33, 0x28, 0x11, 0x11, + 0x16, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x16, 0x11, 0x11, 0x83, 0x54, + 0x45, 0x38, 0x11, 0x11, 0x61, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, + 0x61, 0x18, 0x77, 0x44, 0x44, 0x77, 0x81, 0x16, 0x11, 0x11, 0x00, 0x00, + 0x06, 0x11, 0x00, 0x0c, 0x87, 0x66, 0x48, 0x44, 0x66, 0x78, 0x06, 0x11, + 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x18, 0x76, 0x66, 0x48, 0x44, 0x66, + 0x67, 0x81, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x18, 0x66, + 0x86, 0x38, 0x83, 0x66, 0x66, 0x81, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, + 0x11, 0x11, 0x87, 0x67, 0x87, 0x37, 0x63, 0x76, 0x66, 0x78, 0x11, 0x11, + 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x86, 0x78, 0x86, 0x36, 0x73, 0x67, + 0x67, 0x68, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, 0x66, 0x61, 0x86, 0x68, + 0x83, 0x67, 0x76, 0x36, 0x76, 0x68, 0x16, 0x66, 0x00, 0x00, 0x00, 0x18, + 0x11, 0x11, 0x86, 0x78, 0x85, 0x77, 0x77, 0x57, 0x77, 0x68, 0x11, 0x11, + 0x00, 0x00, 0x00, 0x18, 0x11, 0x11, 0x87, 0x67, 0x88, 0x78, 0x77, 0x88, + 0x76, 0x78, 0x11, 0x11, 0x00, 0x00, 0x00, 0x08, 0x11, 0x11, 0x18, 0x66, + 0x06, 0x88, 0x00, 0x0a, 0x77, 0x77, 0x81, 0x11, 0x11, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x11, 0x11, 0x18, 0x76, 0x78, 0x77, 0x77, 0x76, 0x76, 0x81, + 0x11, 0x11, 0x00, 0x00, 0x06, 0x11, 0x02, 0x87, 0x08, 0x67, 0x02, 0x68, + 0x06, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x11, 0x11, 0x61, 0x18, 0x76, 0x00, + 0x06, 0x66, 0x00, 0x08, 0x81, 0x16, 0x11, 0x11, 0x00, 0x00, 0x00, 0x18, + 0x11, 0x16, 0x11, 0x11, 0x87, 0x77, 0x77, 0x78, 0x11, 0x11, 0x61, 0x11, + 0x00, 0x00, 0x00, 0x18, 0x11, 0x61, 0x11, 0x11, 0x18, 0x88, 0x88, 0x81, + 0x11, 0x11, 0x16, 0x11, 0x00, 0x01 +}; +const unsigned int bulb_on_bmp_len = 510; diff --git a/firmware/application/fox_bmp.hpp b/firmware/application/fox_bmp.hpp index 98c9213a..21f73bf5 100644 --- a/firmware/application/fox_bmp.hpp +++ b/firmware/application/fox_bmp.hpp @@ -1,4 +1,4 @@ -unsigned char fox_bmp[] = { +const unsigned char fox_bmp[] = { 0x42, 0x4d, 0xee, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x78, 0x2b, diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 7aba6fc2..363b8381 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -19,6 +19,9 @@ * Boston, MA 02110-1301, USA. */ +// Bitmaps generated with: +// Gimp :(, then "xxd -i *.bmp" + //BUG: No audio in about when shown second time //BUG: Description doesn't show up first time going to system>module info (UI drawn on top) //TODO: Breakout game diff --git a/firmware/application/splash.hpp b/firmware/application/splash.hpp index bc90176a..4891e7a9 100644 --- a/firmware/application/splash.hpp +++ b/firmware/application/splash.hpp @@ -1,7 +1,4 @@ -// Generated with: -// Gimp :(, then "xxd -i *.bmp" - -unsigned char splash_bmp[] = { +const unsigned char splash_bmp[] = { 0x42, 0x4d, 0x28, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb2, 0x31, diff --git a/firmware/application/ui_closecall.cpp b/firmware/application/ui_closecall.cpp index bb718fb7..69120f89 100644 --- a/firmware/application/ui_closecall.cpp +++ b/firmware/application/ui_closecall.cpp @@ -100,7 +100,7 @@ void CloseCallView::do_detection() { else resolved_frequency = slice_start + (CC_BIN_WIDTH * (imax - 118)); // Init - text_debug.set(to_string_dec_int(CC_BIN_WIDTH * (imax - 118))); //imax + //text_debug.set(to_string_dec_int(CC_BIN_WIDTH * (imax - 118))); // Correct according to DC spike mask width (4 for now) if (iraw > 118) @@ -160,77 +160,76 @@ void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) { uint8_t threshold; size_t i, m; - if (!wait) { - // Spectrum line (for debug) - std::array pixel_row; - for(i = 0; i < 118; i++) { - const auto pixel_color = spectrum_rgb3_lut[spectrum.db[256 - 120 + i]]; - pixel_row[i + 2] = pixel_color; - } - - for(i = 122; i < 240; i++) { - const auto pixel_color = spectrum_rgb3_lut[spectrum.db[i - 120]]; - pixel_row[i - 2] = pixel_color; - } - - display.draw_pixels( - { { 0, 96 + slices_counter * 6 }, { pixel_row.size(), 1 } }, - pixel_row - ); - - // Find max for this slice: - - // Check if left of slice needs to be trimmed (masked) - if (slices_counter == 0) - i = slice_trim; - else - i = 0; - for ( ; i < 118; i++) { - threshold = spectrum.db[256 - 120 + i]; // 128+8 = 136 ~254 - if (threshold > xmax) { - xmax = threshold; - imax = i; - } - } - // Check if right of slice needs to be trimmed (masked) - if (slices_counter == (slices_max - 1)) - m = 240 - slice_trim; - else - m = 240; - for (i = 122 ; i < m; i++) { - threshold = spectrum.db[i - 120]; // 240-120 = 120 -> +8 = 128 - if (threshold > xmax) { // (0~2) 2~120 (120~136) 136~254 (254~256) - xmax = threshold; - imax = i - 4; - } - } - slicemax_db[slices_counter] = xmax; - slicemax_idx[slices_counter] = imax; - - // Add to mean - for (i = 136; i < 254; i++) - mean += spectrum.db[i]; - for (i = 2; i < 120; i++) - mean += spectrum.db[i]; - - // Slice update - if (slicing) { - if (slices_counter >= (slices_max - 1)) { - do_detection(); - mean = 0; - slices_counter = 0; - } else { - slices_counter++; - } - slice_frequency = slice_start + (slices_counter * CC_SLICE_WIDTH); - receiver_model.set_tuning_frequency(slice_frequency); - wait = 1; - } else { - do_detection(); - } - } else { - wait--; + baseband::spectrum_streaming_stop; + + // Spectrum line (for debug) + std::array pixel_row; + for(i = 0; i < 118; i++) { + const auto pixel_color = spectrum_rgb3_lut[spectrum.db[256 - 120 + i]]; + pixel_row[i + 2] = pixel_color; } + + for(i = 122; i < 240; i++) { + const auto pixel_color = spectrum_rgb3_lut[spectrum.db[i - 120]]; + pixel_row[i - 2] = pixel_color; + } + + display.draw_pixels( + { { 0, 96 + slices_counter * 4 }, { pixel_row.size(), 1 } }, + pixel_row + ); + + // Find max for this slice: + + // Check if left of slice needs to be trimmed (masked) + if (slices_counter == 0) + i = slice_trim; + else + i = 0; + for ( ; i < 118; i++) { + threshold = spectrum.db[256 - 120 + i]; // 128+8 = 136 ~254 + if (threshold > xmax) { + xmax = threshold; + imax = i; + } + } + // Check if right of slice needs to be trimmed (masked) + if (slices_counter == (slices_max - 1)) + m = 240 - slice_trim; + else + m = 240; + for (i = 122 ; i < m; i++) { + threshold = spectrum.db[i - 120]; // 240-120 = 120 -> +8 = 128 + if (threshold > xmax) { // (0~2) 2~120 (120~136) 136~254 (254~256) + xmax = threshold; + imax = i - 4; + } + } + slicemax_db[slices_counter] = xmax; + slicemax_idx[slices_counter] = imax; + + // Add to mean + for (i = 136; i < 254; i++) + mean += spectrum.db[i]; + for (i = 2; i < 120; i++) + mean += spectrum.db[i]; + + // Slice update + if (slicing) { + if (slices_counter >= (slices_max - 1)) { + do_detection(); + mean = 0; + slices_counter = 0; + } else { + slices_counter++; + } + slice_frequency = slice_start + (slices_counter * CC_SLICE_WIDTH); + receiver_model.set_tuning_frequency(slice_frequency); + } else { + do_detection(); + } + + baseband::spectrum_streaming_start(1); } void CloseCallView::on_show() { @@ -266,9 +265,7 @@ void CloseCallView::on_range_changed() { rf::Frequency slices_span; rf::Frequency resolved_frequency; int64_t offset; - - // DEBUG - /* + f_max = field_frequency_max.value(); f_min = field_frequency_min.value(); scan_span = abs(f_max - f_min); @@ -288,7 +285,6 @@ void CloseCallView::on_range_changed() { slice_start = slice_frequency; receiver_model.set_tuning_frequency(slice_frequency); - // DEBUG resolved_frequency = (CC_SLICE_WIDTH - scan_span) / 2; // Trim frequency span (for both sides) resolved_frequency /= CC_BIN_WIDTH; // Convert to bin span slice_trim = resolved_frequency; @@ -300,8 +296,9 @@ void CloseCallView::on_range_changed() { slices_max = 1; slices_counter = 0; slicing = false; - }*/ + } + /* f_min = field_frequency_min.value(); scan_span = 3000000; slice_frequency = (f_min + 1500000); @@ -312,6 +309,7 @@ void CloseCallView::on_range_changed() { slices_counter = 0; slicing = false; field_frequency_max.set_value(f_min + 3000000); +*/ text_slices.set(to_string_dec_int(slices_max)); slices_counter = 0; diff --git a/firmware/application/ui_closecall.hpp b/firmware/application/ui_closecall.hpp index aac5f66d..6b43d6fa 100644 --- a/firmware/application/ui_closecall.hpp +++ b/firmware/application/ui_closecall.hpp @@ -61,7 +61,6 @@ private: Coord last_pos = 0; ChannelSpectrumFIFO* fifo { nullptr }; uint8_t detect_counter = 0, release_counter = 0; - uint8_t wait = 2; uint8_t slice_trim; uint32_t mean = 0; uint32_t min_threshold = 80; // Todo: Put this in persistent / settings diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 4b995620..7d0e82e2 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -183,14 +183,15 @@ ReceiverMenuView::ReceiverMenuView(NavigationView& nav) { /* SystemMenuView ********************************************************/ SystemMenuView::SystemMenuView(NavigationView& nav) { - add_items<12>({ { + add_items<11>({ { { "Play dead", ui::Color::red(), [&nav](){ nav.push(false); } }, { "Receiver RX", ui::Color::cyan(), [&nav](){ nav.push(md5_baseband, Receiver); } }, { "Close Call RX", ui::Color::cyan(), [&nav](){ nav.push(md5_baseband, CloseCall); } }, { "Soundboard TX", ui::Color::yellow(), [&nav](){ nav.push(md5_baseband_tx, SoundBoard); } }, //{ "Audio TX", ui::Color::yellow(), [&nav](){ nav.push(md5_baseband_tx, AudioTX); } }, - { "EPAR TX", ui::Color::green(), [&nav](){ nav.push(md5_baseband_tx, EPAR); } }, - { "Xylos TX", ui::Color::orange(), [&nav](){ nav.push(md5_baseband_tx, Xylos); } }, + + //{ "EPAR TX", ui::Color::green(), [&nav](){ nav.push(md5_baseband_tx, EPAR); } }, + { "Xylos TX", ui::Color::green(), [&nav](){ nav.push(md5_baseband_tx, Xylos); } }, { "TEDI/LCR TX", ui::Color::orange(), [&nav](){ nav.push(md5_baseband_tx, LCR); } }, { "RDS TX", ui::Color::yellow(), [&nav](){ nav.push(md5_baseband_tx, RDS); } }, //{ "Capture", ui::Color::white(), [&nav](){ nav.push(); } }, @@ -315,7 +316,7 @@ BMPView::BMPView(NavigationView& nav) { void BMPView::paint(Painter& painter) { (void)painter; - portapack::display.drawBMP({(240-185)/2, 0}, splash_bmp); + portapack::display.drawBMP({(240-185)/2, 0}, splash_bmp, false); } /* PlayDeadView **********************************************************/ diff --git a/firmware/application/ui_xylos.cpp b/firmware/application/ui_xylos.cpp index deed06de..0494b790 100644 --- a/firmware/application/ui_xylos.cpp +++ b/firmware/application/ui_xylos.cpp @@ -43,7 +43,8 @@ using namespace portapack; namespace ui { - + +/* void XylosRXView::talk() { uint8_t c; @@ -79,15 +80,6 @@ XylosRXView::~XylosRXView() { receiver_model.disable(); } -/*VirtualTimer vt; - -void XylosRXView::do_something(void *p) { - //p.set(xylos_voice_filenames[xylos_voice_phrase[p_idx]]); - //p_idx++; - //} while (xylos_voice_phrase[p_idx] != 0xFF); - text_dbg.set("Done :)"); -}*/ - void XylosRXView::on_show() { //chVTSet(&vt, MS2ST(1000), do_something, NULL); } @@ -116,7 +108,7 @@ XylosRXView::XylosRXView( }; } - +*/ @@ -143,10 +135,12 @@ void XylosView::upd_message() { ccirmessage[4] = (city_code.value() / 10) + 0x30; ccirmessage[5] = (city_code.value() % 10) + 0x30; ccirmessage[6] = family_code.value() + 0x30; + if (checkbox_wcsubfamily.value() == false) ccirmessage[7] = subfamily_code.value() + 0x30; else ccirmessage[7] = 'A'; + if (checkbox_wcid.value() == false) { ccirmessage[8] = (receiver_code.value() / 10) + 0x30; ccirmessage[9] = (receiver_code.value() % 10) + 0x30; @@ -160,7 +154,7 @@ void XylosView::upd_message() { ccirmessage[11] = options_ra.selected_index() + 0x30; ccirmessage[12] = options_rb.selected_index() + 0x30; ccirmessage[13] = options_rc.selected_index() + 0x30; - ccirmessage[14] = '0'; + ccirmessage[14] = options_rd.selected_index() + 0x30; ccirmessage[15] = 'B'; @@ -177,7 +171,7 @@ void XylosView::upd_message() { ccirmessage[20] = 0; // Display as text - text_debug.set(ccirmessage); + text_message.set(ccirmessage); // ASCII to frequency LUT index for (c=0; c<20; c++) { @@ -190,19 +184,7 @@ void XylosView::upd_message() { ccirmessage[20] = 0xFF; } -void XylosView::journuit() { - uint8_t sr; - - chThdSleepMilliseconds(1000); - - // Invert relay states - sr = options_ra.selected_index(); - if (sr > 0) options_ra.set_selected_index(sr ^ 3); - sr = options_rb.selected_index(); - if (sr > 0) options_rb.set_selected_index(sr ^ 3); - sr = options_rc.selected_index(); - if (sr > 0) options_rc.set_selected_index(sr ^ 3); - +void XylosView::start_tx() { upd_message(); audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max); @@ -215,18 +197,6 @@ XylosView::XylosView( NavigationView& nav ) { - static constexpr Style style_val { - .font = font::fixed_8x16, - .background = Color::green(), - .foreground = Color::black(), - }; - - static constexpr Style style_cancel { - .font = font::fixed_8x16, - .background = Color::red(), - .foreground = Color::black(), - }; - transmitter_model.set_baseband_configuration({ .mode = 2, .sampling_rate = 1536000, @@ -234,7 +204,7 @@ XylosView::XylosView( }); add_children({ { - &text_title, + &checkbox_hinc, &button_txtest, &text_header, &header_code_a, @@ -251,17 +221,17 @@ XylosView::XylosView( &checkbox_wcid, &text_freq, &options_freq, - &text_ra, + &text_relais, &options_ra, - &text_rb, &options_rb, - &text_rc, &options_rc, - &text_progress, - &text_debug, + &options_rd, + &progress, + &text_message, &button_transmit, &checkbox_cligno, - &button_exit + &tempo_cligno, + &text_cligno } }); city_code.set_value(18); @@ -271,6 +241,9 @@ XylosView::XylosView( header_code_a.set_value(0); header_code_b.set_value(0); options_freq.set_selected_index(5); + tempo_cligno.set_value(5); + + options_ra.set_selected_index(1); // R1 OFF checkbox_wcsubfamily.set_value(true); checkbox_wcid.set_value(true); @@ -299,20 +272,34 @@ XylosView::XylosView( (void)v; XylosView::upd_message(); }; + + subfamily_code.hidden(true); + text_subfamily.set_style(&style_grey); checkbox_wcsubfamily.on_select = [this](Checkbox&) { - if (checkbox_wcsubfamily.value() == true) + if (checkbox_wcsubfamily.value() == true) { subfamily_code.hidden(true); - else + text_subfamily.set_style(&style_grey); + } else { subfamily_code.hidden(false); + text_subfamily.set_style(&style()); + } XylosView::upd_message(); }; + + receiver_code.hidden(true); + text_receiver.set_style(&style_grey); checkbox_wcid.on_select = [this](Checkbox&) { - if (checkbox_wcid.value() == true) + if (checkbox_wcid.value() == true) { receiver_code.hidden(true); - else + text_receiver.set_style(&style_grey); + } else { receiver_code.hidden(false); + text_receiver.set_style(&style()); + } + receiver_code.set_dirty(); XylosView::upd_message(); }; + options_ra.on_change = [this](size_t n, OptionsField::value_t v) { (void)n; (void)v; @@ -328,13 +315,18 @@ XylosView::XylosView( (void)v; XylosView::upd_message(); }; + options_rd.on_change = [this](size_t n, OptionsField::value_t v) { + (void)n; + (void)v; + XylosView::upd_message(); + }; button_transmit.set_style(&style_val); XylosView::upd_message(); button_txtest.on_select = [this](Button&) { - const uint8_t ccirtest[21] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,0xFF }; + const uint8_t ccirtest[21] = { 11, 13, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 14, 12, 10, 12, 14, 0, 9, 0xFF }; if (txing == false) { EventDispatcher::message_map().unregister_handler(Message::ID::TXDone); @@ -345,8 +337,8 @@ XylosView::XylosView( audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max); transmitter_model.disable(); txing = false; - button_txtest.set_style(&style_val); - button_txtest.set_text("TX TEST"); + button_txtest.set_style(&style()); + button_txtest.set_text("TEST"); } } ); @@ -367,36 +359,65 @@ XylosView::XylosView( }; button_transmit.on_select = [this](Button&) { + if (txing == false) { upd_message(); + if (checkbox_hinc.value()) + inc_cnt = 3; + else + inc_cnt = 0; + header_init = header_code_b.value(); + EventDispatcher::message_map().unregister_handler(Message::ID::TXDone); EventDispatcher::message_map().register_handler(Message::ID::TXDone, [this](Message* const p) { - uint8_t c; - char progress[21]; + uint8_t sr; const auto message = static_cast(p); if (message->n == 25) { audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max); transmitter_model.disable(); - for (c=0;c<20;c++) - progress[c] = ' '; - progress[20] = 0; - text_progress.set(progress); - if (checkbox_cligno.value() == false) { - txing = false; - button_transmit.set_style(&style_val); - button_transmit.set_text("START"); + progress.set_value(0); + + if (inc_cnt) { + chThdSleepMilliseconds(1000); + header_code_b.set_value(header_code_b.value() + 1); + + upd_message(); + start_tx(); + + inc_cnt--; } else { - journuit(); + header_code_b.set_value(header_init); + if (checkbox_cligno.value() == false) { + txing = false; + button_transmit.set_style(&style_val); + button_transmit.set_text("START"); + } else { + if (checkbox_hinc.value()) + inc_cnt = 3; + else + inc_cnt = 0; + + chThdSleepMilliseconds(tempo_cligno.value() * 1000); + + // Invert relay states + sr = options_ra.selected_index(); + if (sr > 0) options_ra.set_selected_index(sr ^ 3); + sr = options_rb.selected_index(); + if (sr > 0) options_rb.set_selected_index(sr ^ 3); + sr = options_rc.selected_index(); + if (sr > 0) options_rc.set_selected_index(sr ^ 3); + sr = options_rd.selected_index(); + if (sr > 0) options_rd.set_selected_index(sr ^ 3); + + upd_message(); + start_tx(); + } } } else { - for (c=0;cn;c++) // Todo: Use progressbar ! - progress[c] = ' '; - progress[c] = '.'; - progress[++c] = 0; - text_progress.set(progress); + progress.set_value((message->n + 1) * 5); } } ); @@ -414,10 +435,6 @@ XylosView::XylosView( transmitter_model.enable(); } }; - - button_exit.on_select = [&nav](Button&){ - nav.pop(); - }; } diff --git a/firmware/application/ui_xylos.hpp b/firmware/application/ui_xylos.hpp index 96d88977..1999000d 100644 --- a/firmware/application/ui_xylos.hpp +++ b/firmware/application/ui_xylos.hpp @@ -26,6 +26,11 @@ #include "ui_menu.hpp" #include "ui_navigation.hpp" #include "ui_font_fixed_8x16.hpp" + +#include "bulb_on_bmp.hpp" +#include "bulb_off_bmp.hpp" +#include "bulb_ignore_bmp.hpp" + #include "clock_manager.hpp" #include "message.hpp" #include "rf_path.hpp" @@ -36,6 +41,7 @@ namespace ui { +/* #define XYLOS_VOICE_ZERO 0 #define XYLOS_VOICE_HEADER 16 #define XYLOS_VOICE_RELAYS 21 @@ -134,47 +140,61 @@ private: { 21 * 8, 16 * 16, 64, 32 }, "Exit" }; -}; +};*/ class XylosView : public View { public: XylosView(NavigationView& nav); ~XylosView(); - void journuit(); + std::string title() const override { return "Xylos transmit"; }; - void talk(); + void start_tx(); void upd_message(); void focus() override; void paint(Painter& painter) override; private: + int inc_cnt; + int header_init; bool txing = false; const rf::Frequency xylos_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 }; char ccirmessage[21]; - Text text_title { - { 8, 8, 11, 16 }, - "BH Xylos TX" + const Style style_val { + .font = font::fixed_8x16, + .background = Color::green(), + .foreground = Color::black(), + }; + const Style style_cancel { + .font = font::fixed_8x16, + .background = Color::red(), + .foreground = Color::black(), + }; + const Style style_grey { + .font = font::fixed_8x16, + .background = Color::black(), + .foreground = Color::grey(), }; - Button button_txtest { - { 180, 8, 40, 24 }, - "TEST" + Checkbox checkbox_hinc { + { 21 * 8, 12}, + 2, + "+3" }; Text text_header { - { 8 * 8, 2 * 16, 7 * 8, 16 }, + { 8 * 8, 1 * 16, 7 * 8, 16 }, "Header:" }; NumberField header_code_a { - { 16 * 8, 2 * 16 }, + { 16 * 8, 1 * 16 }, 2, { 0, 99 }, 1, '0' }; NumberField header_code_b { - { 18 * 8, 2 * 16 }, + { 18 * 8, 1 * 16 }, 2, { 0, 99 }, 1, @@ -182,11 +202,11 @@ private: }; Text text_city { - { 4 * 8, 3 * 16, 11 * 8, 16 }, + { 4 * 8, 2 * 16, 11 * 8, 16 }, "Code ville:" }; NumberField city_code { - { 16 * 8, 3 * 16 }, + { 16 * 8, 2 * 16 }, 2, { 0, 99 }, 1, @@ -194,57 +214,57 @@ private: }; Text text_family { - { 7 * 8, 4 * 16, 8 * 8, 16 }, + { 7 * 8, 3 * 16, 8 * 8, 16 }, "Famille:" }; NumberField family_code { - { 16 * 8, 4 * 16 }, - 2, + { 16 * 8, 3 * 16 }, + 1, { 0, 9 }, 1, ' ' }; Text text_subfamily { - { 2 * 8, 5 * 16 + 4, 13 * 8, 16 }, + { 2 * 8, 4 * 16 + 4, 13 * 8, 16 }, "Sous-famille:" }; NumberField subfamily_code { - { 16 * 8, 5 * 16 + 4 }, - 2, + { 16 * 8, 4 * 16 + 4 }, + 1, { 0, 9 }, 1, ' ' }; Checkbox checkbox_wcsubfamily { - { 20 * 8, 5 * 16}, + { 20 * 8, 4 * 16}, 6, "Toutes" }; Text text_receiver { - { 2 * 8, 7 * 16 + 6, 13 * 8, 16 }, + { 2 * 8, 6 * 16, 13 * 8, 16 }, "ID recepteur:" }; NumberField receiver_code { - { 16 * 8, 7 * 16 + 6 }, + { 16 * 8, 6 * 16 }, 2, { 0, 99 }, 1, ' ' }; Checkbox checkbox_wcid { - { 20 * 8, 7 * 16 + 4}, + { 20 * 8, 6 * 16 }, 4, "Tous" }; Text text_freq { - { 5 * 8, 9 * 16, 10 * 8, 16 }, + { 6 * 8, 8 * 16, 10 * 8, 16 }, "Frequence:" }; OptionsField options_freq { - { 16 * 8, 9 * 16 + 4}, + { 17 * 8, 8 * 16}, 7, { { "31.3250", 0 }, @@ -257,51 +277,48 @@ private: } }; - Text text_ra { - { 12, 11 * 16, 8 * 8, 16 }, - "Relais 1" + Text text_relais { + { 8, 9 * 16 + 4, 7 * 8, 16 }, + "Relais:" }; - OptionsField options_ra { - { 16, 12 * 16 }, - 3, + + ImageOptionsField options_ra { + { 26, 166, 24, 24 }, { - { "Ignorer", 0 }, - { " OFF ", 1 }, - { " ON ", 2 } + { &bulb_ignore_bmp[0], 0 }, + { &bulb_off_bmp[0], 1 }, + { &bulb_on_bmp[0], 2 } } }; - Text text_rb { - { 88, 11 * 16, 8 * 8, 16 }, - "Relais 2" - }; - OptionsField options_rb { - { 92, 12 * 16 }, - 3, + ImageOptionsField options_rb { + { 79, 166, 24, 24 }, { - { "Ignorer", 0 }, - { " OFF ", 1 }, - { " ON ", 2 } + { &bulb_ignore_bmp[0], 0 }, + { &bulb_off_bmp[0], 1 }, + { &bulb_on_bmp[0], 2 } } }; - Text text_rc { - { 164, 11 * 16, 8 * 8, 16 }, - "Relais 3" - }; - OptionsField options_rc { - { 168, 12 * 16 }, - 3, + ImageOptionsField options_rc { + { 133, 166, 24, 24 }, { - { "Ignorer", 0 }, - { " OFF ", 1 }, - { " ON ", 2 } + { &bulb_ignore_bmp[0], 0 }, + { &bulb_off_bmp[0], 1 }, + { &bulb_on_bmp[0], 2 } + } + }; + ImageOptionsField options_rd { + { 186, 166, 24, 24 }, + { + { &bulb_ignore_bmp[0], 0 }, + { &bulb_off_bmp[0], 1 }, + { &bulb_on_bmp[0], 2 } } }; - Text text_progress { + ProgressBar progress { { 5 * 8, 13 * 16, 20 * 8, 16 }, - " " }; - Text text_debug { + Text text_message { { 5 * 8, 14 * 16, 20 * 8, 16 }, "--------------------" }; @@ -312,14 +329,25 @@ private: }; Checkbox checkbox_cligno { - { 96, 16 * 16 + 4}, + { 96, 16 * 16}, 3, "J/N" }; + NumberField tempo_cligno { + { 104, 16 * 16 + 28 }, + 2, + { 1, 99 }, + 1, + ' ' + }; + Text text_cligno { + { 104 + 16, 16 * 16 + 28, 2 * 8, 16 }, + "s." + }; - Button button_exit { - { 21 * 8, 16 * 16, 64, 32 }, - "Exit" + Button button_txtest { + { 20 * 8, 16 * 16, 64, 32 }, + "TEST" }; }; diff --git a/firmware/baseband-tx.bin b/firmware/baseband-tx.bin index de0e480b..0bbd08fb 100644 Binary files a/firmware/baseband-tx.bin and b/firmware/baseband-tx.bin differ diff --git a/firmware/baseband-tx/proc_xylos.cpp b/firmware/baseband-tx/proc_xylos.cpp index 8d6de4d9..5c4e2069 100644 --- a/firmware/baseband-tx/proc_xylos.cpp +++ b/firmware/baseband-tx/proc_xylos.cpp @@ -42,47 +42,61 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) { if (s >= 9) { s = 0; - if (sample_count >= CCIR_TONELENGTH) { - if (shared_memory.transmit_done == false) { - message.n = byte_pos; // Inform UI about progress (just as eye candy) - shared_memory.application_queue.push(message); - digit = shared_memory.xylosdata[byte_pos++]; + if (silence) { + if (sample_count >= SILENCE) { + silence = false; + sample_count = CCIR_TONELENGTH; + } else { + sample_count++; } + } else { + if (sample_count >= CCIR_TONELENGTH) { + if (shared_memory.transmit_done == false) { + message.n = byte_pos; // Inform UI about progress (just as eye candy) + shared_memory.application_queue.push(message); + digit = shared_memory.xylosdata[byte_pos++]; + } + + if (digit == 0xFF) { + message.n = 25; // End of message code + shared_memory.transmit_done = true; + shared_memory.application_queue.push(message); + } - if (digit == 0xFF) { - message.n = 25; // End of message code - shared_memory.transmit_done = true; - shared_memory.application_queue.push(message); + sample_count = 0; + } else { + sample_count++; } - sample_count = 0; - } else { - sample_count++; + aphase += ccir_phases[digit]; } - - aphase += ccir_phases[digit]; } else { s++; } - sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*255); - - // Audio preview sample generation: 1536000/48000 = 32 - /*if (as >= 31) { - as = 0; - audio[ai++] = sample * 128; + if (silence) { + re = 0; + im = 0; } else { - as++; - }*/ - - //FM - frq = sample * 1000; // ~25kHz wide - - phase = (phase + frq); - sphase = phase + (256<<16); + sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*255); + + // Audio preview sample generation: 1536000/48000 = 32 + /*if (as >= 31) { + as = 0; + audio[ai++] = sample * 128; + } else { + as++; + }*/ + + //FM + frq = sample * 500; // To check ! + + phase = (phase + frq); + sphase = phase + (256<<16); - re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*127); - im = (sine_table_f32[(phase & 0x03FF0000)>>18]*127); + re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*127); + im = (sine_table_f32[(phase & 0x03FF0000)>>18]*127); + } buffer.p[i] = {(int8_t)re,(int8_t)im}; } diff --git a/firmware/baseband-tx/proc_xylos.hpp b/firmware/baseband-tx/proc_xylos.hpp index 1de15d16..1a7b2cf3 100644 --- a/firmware/baseband-tx/proc_xylos.hpp +++ b/firmware/baseband-tx/proc_xylos.hpp @@ -31,8 +31,9 @@ #include "audio_output.hpp" #include "baseband_processor.hpp" -#define CCIR_TONELENGTH 15360-1 // 1536000/10/10 -#define PHASEV 436.91 // (65536*1024)/1536000*10 +#define CCIR_TONELENGTH 15360-1 // 1536000/10/10 +#define PHASEV 436.91 // (65536*1024)/1536000*10 +#define SILENCE 61440-1 // 400ms class XylosProcessor : public BasebandProcessor { public: @@ -73,6 +74,7 @@ private: uint32_t sample_count = CCIR_TONELENGTH; uint32_t aphase, phase, sphase; int32_t sample, frq; + bool silence = true; TXDoneMessage message; //AudioOutput audio_output; diff --git a/firmware/baseband.bin b/firmware/baseband.bin index be9eda36..a877db80 100644 Binary files a/firmware/baseband.bin and b/firmware/baseband.bin differ diff --git a/firmware/baseband/proc_closecall.cpp b/firmware/baseband/proc_closecall.cpp index 22ff7d12..2b6bb069 100644 --- a/firmware/baseband/proc_closecall.cpp +++ b/firmware/baseband/proc_closecall.cpp @@ -38,7 +38,7 @@ void CloseCallProcessor::execute(const buffer_c8_t& buffer) { spectrum[i] += buffer.p[i + 1024]; } - if( phase == 50 ) { + if( phase == 20 ) { const buffer_c16_t buffer_c16 { spectrum.data(), spectrum.size(), diff --git a/firmware/bitmaps/bulb_ignore.bmp b/firmware/bitmaps/bulb_ignore.bmp new file mode 100644 index 00000000..1bcd2e87 Binary files /dev/null and b/firmware/bitmaps/bulb_ignore.bmp differ diff --git a/firmware/bitmaps/bulb_off.bmp b/firmware/bitmaps/bulb_off.bmp new file mode 100644 index 00000000..fbd18b70 Binary files /dev/null and b/firmware/bitmaps/bulb_off.bmp differ diff --git a/firmware/bitmaps/bulb_on.bmp b/firmware/bitmaps/bulb_on.bmp new file mode 100644 index 00000000..8ebc52f1 Binary files /dev/null and b/firmware/bitmaps/bulb_on.bmp differ diff --git a/firmware/bitmaps/fox.bmp b/firmware/bitmaps/fox.bmp new file mode 100644 index 00000000..2556fa22 Binary files /dev/null and b/firmware/bitmaps/fox.bmp differ diff --git a/firmware/bitmaps/fox_rle.bmp b/firmware/bitmaps/fox_rle.bmp new file mode 100644 index 00000000..9c491783 Binary files /dev/null and b/firmware/bitmaps/fox_rle.bmp differ diff --git a/firmware/application/splash.bmp b/firmware/bitmaps/splash.bmp similarity index 100% rename from firmware/application/splash.bmp rename to firmware/bitmaps/splash.bmp diff --git a/firmware/common/lcd_ili9341.cpp b/firmware/common/lcd_ili9341.cpp index 5fa4f7c7..5dca2d3a 100644 --- a/firmware/common/lcd_ili9341.cpp +++ b/firmware/common/lcd_ili9341.cpp @@ -289,17 +289,18 @@ void ILI9341::render_box(const ui::Point p, const ui::Size s, const ui::Color* l io.lcd_write_pixels(line_buffer, s.w * s.h); } -void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap) { +void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool transparency) { uint32_t pixel_data, pal_data; - uint8_t pal, by, c, count; + uint8_t pal, by, c, count, transp_idx = 0, color_r, color_g, color_b; ui::Color linebuffer[240]; ui::Coord px = 0, py; ui::Color palette[16]; uint32_t bmpwidth, bmpheight; - // RLE_4 BMP loader with hardcoded size and no delta :( + // RLE_4 BMP loader with no delta :( if (bitmap[0x1E] != 2) return; // Bad compression type + bmpwidth = static_cast( (bitmap[0x12]) | (bitmap[0x13] << 8) | @@ -316,41 +317,88 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap) { pixel_data = bitmap[0x0A]; pal = 0; for (c = 0; c < (16*4); c+=4) { - palette[pal++] = ui::Color(bitmap[c+2+pal_data], bitmap[c+1+pal_data], bitmap[c+pal_data]); + color_r = bitmap[c+2+pal_data]; + color_g = bitmap[c+1+pal_data]; + color_b = bitmap[c+pal_data]; + palette[pal] = ui::Color(color_r, color_g, color_b); + if ((color_r == 0xFF) && (color_g == 0x00) && (color_b == 0xFF)) transp_idx = pal; + pal++; } - py = bmpheight + 16; - do { - by = bitmap[pixel_data++]; - if (by) { - count = by; + if (!transparency) { + py = bmpheight + 16; // +1 ? + do { by = bitmap[pixel_data++]; - for (c = 0; c < count; c+=2) { - linebuffer[px++] = palette[by >> 4]; - if (px < bmpwidth) linebuffer[px++] = palette[by & 15]; - } - if (pixel_data & 1) pixel_data++; - } else { - by = bitmap[pixel_data++]; - if (by == 0) { - render_line({p.x, p.y + py}, bmpwidth, linebuffer); - py--; - px = 0; - } else if (by == 1) { - break; - } else if (by == 2) { - // Delta - } else { + if (by) { count = by; + by = bitmap[pixel_data++]; for (c = 0; c < count; c+=2) { - by = bitmap[pixel_data++]; linebuffer[px++] = palette[by >> 4]; if (px < bmpwidth) linebuffer[px++] = palette[by & 15]; } if (pixel_data & 1) pixel_data++; + } else { + by = bitmap[pixel_data++]; + if (by == 0) { + render_line({p.x, p.y + py}, bmpwidth, linebuffer); + py--; + px = 0; + } else if (by == 1) { + break; + } else if (by == 2) { + // Delta + } else { + count = by; + for (c = 0; c < count; c+=2) { + by = bitmap[pixel_data++]; + linebuffer[px++] = palette[by >> 4]; + if (px < bmpwidth) linebuffer[px++] = palette[by & 15]; + } + if (pixel_data & 1) pixel_data++; + } } - } - } while (1); + } while (1); + } else { + py = bmpheight; // +1 ? + do { + by = bitmap[pixel_data++]; + if (by) { + count = by; + by = bitmap[pixel_data++]; + for (c = 0; c < count; c+=2) { + if ((by >> 4) != transp_idx) draw_pixel({static_cast(p.x + px), static_cast(p.y + py)}, palette[by >> 4]); + px++; + if (px < bmpwidth) { + if ((by & 15) != transp_idx) draw_pixel({static_cast(p.x + px), static_cast(p.y + py)}, palette[by & 15]); + } + px++; + } + if (pixel_data & 1) pixel_data++; + } else { + by = bitmap[pixel_data++]; + if (by == 0) { + py--; + px = 0; + } else if (by == 1) { + break; + } else if (by == 2) { + // Delta + } else { + count = by; + for (c = 0; c < count; c+=2) { + by = bitmap[pixel_data++]; + if ((by >> 4) != transp_idx) draw_pixel({static_cast(p.x + px), static_cast(p.y + py)}, palette[by >> 4]); + px++; + if (px < bmpwidth) { + if ((by & 15) != transp_idx) draw_pixel({static_cast(p.x + px), static_cast(p.y + py)}, palette[by & 15]); + } + px++; + } + if (pixel_data & 1) pixel_data++; + } + } + } while (1); + } } void ILI9341::draw_line(const ui::Point start, const ui::Point end, const ui::Color color) { diff --git a/firmware/common/lcd_ili9341.hpp b/firmware/common/lcd_ili9341.hpp index 14957d6f..a3d29f21 100644 --- a/firmware/common/lcd_ili9341.hpp +++ b/firmware/common/lcd_ili9341.hpp @@ -57,7 +57,7 @@ public: ); void draw_pixel(const ui::Point p, const ui::Color color); - void drawBMP(const ui::Point p, const uint8_t * bitmap); + void drawBMP(const ui::Point p, const uint8_t * bitmap, const bool transparency); void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer); void render_box(const ui::Point p, const ui::Size s, const ui::Color* line_buffer); diff --git a/firmware/common/modules.h b/firmware/common/modules.h index dc5f0c10..aefa79ff 100644 --- a/firmware/common/modules.h +++ b/firmware/common/modules.h @@ -1,2 +1,2 @@ -const char md5_baseband[16] = {0x95,0x5d,0xe3,0x7e,0xf1,0x75,0x8b,0x1a,0x27,0xea,0x09,0xb7,0xb9,0xdc,0x7e,0xe2,}; -const char md5_baseband_tx[16] = {0x72,0xf5,0x35,0x17,0x37,0x57,0xd7,0x28,0x5f,0xc5,0x8a,0xc0,0x0b,0x71,0xd4,0xd1,}; +const char md5_baseband[16] = {0xb8,0x9e,0x9b,0x08,0x44,0x34,0x04,0x20,0x0b,0xbc,0x60,0x7e,0x67,0x88,0x53,0xf7,}; +const char md5_baseband_tx[16] = {0xf2,0x82,0xb2,0x1e,0xc7,0xaa,0x15,0x73,0x02,0x74,0xbf,0x51,0xbe,0x6c,0xca,0xd0,}; diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 0133f310..b6f8afbe 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -715,6 +715,83 @@ bool ImageButton::on_touch(const TouchEvent event) { } } +/* ImageOptionsField *****************************************************/ + +ImageOptionsField::ImageOptionsField( + Rect parent_rect, + options_t options +) : Widget { parent_rect }, + options { options } +{ + set_focusable(true); +} + +size_t ImageOptionsField::selected_index() const { + return selected_index_; +} + +size_t ImageOptionsField::selected_index_value() const { + return options[selected_index_].second; +} + +void ImageOptionsField::set_selected_index(const size_t new_index) { + if( new_index < options.size() ) { + if( new_index != selected_index() ) { + selected_index_ = new_index; + if( on_change ) { + on_change(selected_index(), options[selected_index()].second); + } + set_dirty(); + } + } +} + +void ImageOptionsField::set_by_value(value_t v) { + size_t new_index { 0 }; + for(const auto& option : options) { + if( option.second == v ) { + set_selected_index(new_index); + break; + } + new_index++; + } +} + +void ImageOptionsField::set_options(options_t new_options) { + options = new_options; + set_by_value(0); + set_dirty(); +} + +void ImageOptionsField::paint(Painter& painter) { + const auto paint_style = has_focus() ? style().invert() : style(); + + if( selected_index() < options.size() ) { + const auto bmp_ptr = options[selected_index()].first; + portapack::display.fill_rectangle({screen_rect().pos, {screen_rect().size.w + 4, screen_rect().size.h + 4}}, ui::Color::black()); + painter.draw_rectangle({screen_rect().pos, {screen_rect().size.w + 4, screen_rect().size.h + 4}}, paint_style.background); + portapack::display.drawBMP({screen_pos().x + 2, screen_pos().y + 1}, bmp_ptr, true); + } +} + +void ImageOptionsField::on_focus() { + if( on_show_options ) { + on_show_options(); + } +} + +bool ImageOptionsField::on_encoder(const EncoderEvent delta) { + set_selected_index(selected_index() + delta); + return true; +} + +bool ImageOptionsField::on_touch(const TouchEvent event) { + if( event.type == TouchEvent::Type::Start ) { + focus(); + } + return true; +} + /* OptionsField **********************************************************/ OptionsField::OptionsField( diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index d9602f52..eda09257 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -305,6 +305,37 @@ public: bool on_touch(const TouchEvent event) override; }; +class ImageOptionsField : public Widget { +public: + using image_t = const unsigned char *; + using value_t = int32_t; + using option_t = std::pair; + using options_t = std::vector; + + std::function on_change; + std::function on_show_options; + + ImageOptionsField(Rect parent_rect, options_t options); + + void set_options(options_t new_options); + + size_t selected_index() const; + size_t selected_index_value() const; + void set_selected_index(const size_t new_index); + + void set_by_value(value_t v); + + void paint(Painter& painter) override; + + void on_focus() override; + bool on_encoder(const EncoderEvent delta) override; + bool on_touch(const TouchEvent event) override; + +private: + options_t options; + size_t selected_index_ { 0 }; +}; + class OptionsField : public Widget { public: using name_t = std::string; diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index 70ebbe6a..0c1ec1bf 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ diff --git a/sdcard/baseband-tx.bin b/sdcard/baseband-tx.bin index de0e480b..0bbd08fb 100644 Binary files a/sdcard/baseband-tx.bin and b/sdcard/baseband-tx.bin differ diff --git a/sdcard/baseband.bin b/sdcard/baseband.bin index be9eda36..a877db80 100644 Binary files a/sdcard/baseband.bin and b/sdcard/baseband.bin differ