diff --git a/Production/firmware/mai_pico.uf2 b/Production/firmware/mai_pico.uf2 index 05c979e..a7fc89e 100644 Binary files a/Production/firmware/mai_pico.uf2 and b/Production/firmware/mai_pico.uf2 differ diff --git a/README.md b/README.md index 163f5ec..2f6b9ad 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,15 @@ This project is the most complex one among all my projects. ## About the License It's CC-NC. So DIY for yourself and for your friend for free, don't make money from it. And plagiarism that doesn’t even dare to mention the original author is not acceptable. Plase note that pooling orders and group buying for raw materials is acceptable. Selling off any leftover components without profit is also acceptable. -If you're interested in buying from me or some kind of commercial use, please contact me (Discord, QQ group, Wechat group or leave your contact in issue section). - -## My Discord Invitation -https://discord.gg/M8f2PPQFEA +If you're interested in buying from me or some kind of commercial use, please contact me (Discord, QQ group, Goofish). +* My Discord Invitation: https://discord.gg/M8f2PPQFEA +* QQ Group: 854535476 +* Goofish: whowe12345 ## My Other Projects You can check out my other cool projects. - + * Popn Pico: https://github.com/whowechina/popn_pico * IIDX Pico: https://github.com/whowechina/iidx_pico @@ -51,7 +51,8 @@ You can check out my other cool projects. * Musec Pico: https://github.com/whowechina/musec_pico * Ju Pico: https://github.com/whowechina/ju_pico * Bishi Pico: https://github.com/whowechina/bishi_pico -* Bishi Pico: https://github.com/whowechina/nos_pico +* Nos Pico: https://github.com/whowechina/nos_pico +* Voltex Pico: https://github.com/whowechina/voltex_pico ## **Disclaimer** ## I made this project in my personal time without any sponsorship. I will continue to improve the project. I have done my best to ensure that everything is accurate and functional, there's always a chance that mistakes may occur. I cannot be held responsible for any loss of your time or money that may result from using this open source project. Thank you for your understanding. @@ -139,7 +140,6 @@ Before we start, I want to encourage you with some hobbyist builds. * Install the cover, each needs 2x M2*5mm screws. - ### Portable Display * Resolution: 1920*1080, size: 15.6inch, refresh rate: 120Hz (recommended) or 60Hz, built-in speakers. * They're easy to find. Choose cheap or even tiny-flawed ones, they're much cheaper and work just fine. @@ -154,6 +154,12 @@ Before we start, I want to encourage you with some hobbyist builds. ### Housing * It's your job to design it and make it look nice. +### RGB Light + * All RGB lights are daisy-chained in just one WS2812B chain following this order: + * [8x Button Nodes] -> [3x Cabinet Nodes] -> [1x Banner Node] -> [1x AIME Node] + * You can set chained RGB LED numbers for each node (Button, Cabinet or Banner) using `rgb` command. `0` means ignore the nodes. Note that AIME node supports up to 16 LEDs, and you can't change it. + * If two or more RGB LEDs are connected parallelly (sharing the same input), they're considered as one node. + ### Firmware * UF2 file is in `Production\Firmware` folder. * For the new build, hold the BOOTSEL button while connect the USB to a PC, there will be a disk named "RPI-RP2" showed up. Drag the UF2 firmware binary file into it. That's it. diff --git a/README_CN.md b/README_CN.md index f699e08..a76e837 100644 --- a/README_CN.md +++ b/README_CN.md @@ -31,15 +31,15 @@ ## 关于许可证 它是 CC-NC 授权。所以你只能给自己和或者免费给你的朋友 DIY,不能利用这个项目赚钱,比如收费的代做,出售整机等,连源作者都不敢提的抄袭或者稍微改改换个名字来打擦边球就更不可以了。注意团购和拼单订购原始元器件是合理的,非盈利的方式卖掉剩余的元器件也是可以接受的。 -如果希望找我购买成品或者寻求商用授权,请联系我(Discord,QQ 群,闲鱼,微信群或者在 issue 区留下你的联系方式)。 - -## 我的 Discord 服务器邀请 -https://discord.gg/M8f2PPQFEA +如果希望找我购买成品或者获取商用授权,请联系我(Discord,QQ 群,闲鱼)。 +* Discord 服务器邀请:https://discord.gg/M8f2PPQFEA +* QQ 群:854535476 +* 闲鱼:whowe12345 ## 其他项目 你也可以查看我其他的酷炫项目。 - + * Popn Pico: https://github.com/whowechina/popn_pico * IIDX Pico: https://github.com/whowechina/iidx_pico @@ -53,7 +53,8 @@ https://discord.gg/M8f2PPQFEA * Musec Pico: https://github.com/whowechina/musec_pico * Ju Pico: https://github.com/whowechina/ju_pico * Bishi Pico: https://github.com/whowechina/bishi_pico -* Bishi Pico: https://github.com/whowechina/nos_pico +* Nos Pico: https://github.com/whowechina/nos_pico +* Voltex Pico: https://github.com/whowechina/voltex_pico ## **声明** ## 我在个人业余时间内制作了这个项目(没有任何赞助),并且会持续改进这个项目。我已尽我所能确保所有内容的准确性和功能性,但总有可能出现错误。如果你因使用这个开源项目而造成时间或金钱的损失,我不能负责。感谢你的理解。 @@ -156,6 +157,12 @@ https://discord.gg/M8f2PPQFEA ### 外壳 * 设计并使其看起来漂亮是你的工作。 +### RGB 灯光 + * 所有 WS2812 LED 都是串接在一条 RGB 线路上的,顺序如下: + * [8x 按钮节点] --> [3x 机框节点] --> [1x 顶灯节点] --> [1x AIME 节点] + * 你可以使用 `rgb` 命令为每个节点(按钮、机框或顶灯)设置串联的 RGB LED 数量。设置 `0` 表示忽略该类节点。请注意,AIME 节点支持最多 16 个 LED,且无法更改。 + * 如果多个 RGB LED 并联(共享相同输入),则视为一个节点。 + ### 固件 * UF2 文件在 `Production\Firmware` 文件夹中。 * 对于新的构建,连接 USB 到 PC 时按住 BOOTSEL 按钮,会出现一个名为 "RPI-RP2" 的磁盘。将 UF2 固件二进制文件拖入其中。就这样。 diff --git a/firmware/src/commands.c b/firmware/src/commands.c index 1d90038..dec9f95 100644 --- a/firmware/src/commands.c +++ b/firmware/src/commands.c @@ -25,10 +25,11 @@ static void disp_rgb() { printf("[RGB]\n"); - printf(" Number per button: %d, number per cab: %d\n", - mai_cfg->rgb.per_button, mai_cfg->rgb.per_cab); - printf(" Key on: %06lx, off: %06lx\n Level: %d\n", - mai_cfg->color.key_on, mai_cfg->color.key_off, mai_cfg->color.level); + printf(" LED Number for Button: %d\n" + " LED Number for Cabinet Light: %d\n" + " LED Number for Banner: %d\n", + mai_cfg->rgb.per_button, mai_cfg->rgb.per_cab, mai_cfg->rgb.per_banner); + printf(" Level: %d\n", mai_cfg->color.level); } static void print_sense_zone(const char *title, const int8_t *zones, int num) @@ -157,21 +158,28 @@ void handle_display(int argc, char *argv[]) static void handle_rgb(int argc, char *argv[]) { - const char *usage = "Usage: rgb <1..16> <0..128>\n"; - if (argc != 2) { + const char *usage = "Usage: rgb \n" + " per_button: [0..15] LED number per button\n" + " per_cab: [0..15] LED number for each cabinet light\n" + " per_banner: [0..15] LED number for the banner\n"; + if (argc != 3) { printf(usage); return; } int per_button = cli_extract_non_neg_int(argv[0], 0); - int per_cab = cli_extract_non_neg_int(argv[1], 0); - if ((per_button < 1) || (per_button > 16) || (per_cab > 128)) { + int per_cab = cli_extract_non_neg_int(argv[1], 0); + int per_banner = cli_extract_non_neg_int(argv[2], 0); + + if ((per_button < 0) || (per_cab < 0) || (per_banner < 0) || + (per_button > 15) || (per_cab > 15) || (per_banner > 15)) { printf(usage); return; } mai_cfg->rgb.per_button = per_button; mai_cfg->rgb.per_cab = per_cab; + mai_cfg->rgb.per_banner = per_banner; config_changed(); disp_rgb(); diff --git a/firmware/src/config.c b/firmware/src/config.c index e76c564..df62803 100644 --- a/firmware/src/config.c +++ b/firmware/src/config.c @@ -16,8 +16,6 @@ mai_cfg_t *mai_cfg; static mai_cfg_t default_cfg = { .color = { - .key_on = 0xc0c0c0, - .key_off = 0x080808, .level = 127, }, .sense = { diff --git a/firmware/src/config.h b/firmware/src/config.h index ee3d2c7..1606a0c 100644 --- a/firmware/src/config.h +++ b/firmware/src/config.h @@ -13,8 +13,7 @@ typedef struct __attribute__((packed)) { struct { - uint32_t key_on; - uint32_t key_off; + uint32_t not_used[2]; uint8_t level; } color; struct { @@ -30,7 +29,8 @@ typedef struct __attribute__((packed)) { } hid; struct { uint8_t per_button; - uint8_t per_cab; + uint8_t per_cab : 4; + uint8_t per_banner : 4; } rgb; struct { uint8_t buttons[12]; diff --git a/firmware/src/hid.c b/firmware/src/hid.c index a6e0f79..79b4eb9 100644 --- a/firmware/src/hid.c +++ b/firmware/src/hid.c @@ -6,6 +6,7 @@ #include "tusb.h" #include "usb_descriptors.h" #include "button.h" +#include "rgb.h" #include "config.h" #include "hid.h" @@ -106,14 +107,27 @@ void hid_update() typedef struct __attribute__((packed)) { uint8_t report_id; uint8_t cmd; - uint8_t payload[62]; + union { + struct { + uint8_t led; + uint8_t gap; + uint8_t r1; + uint8_t r2; + uint8_t g1; + uint8_t g2; + uint8_t b1; + uint8_t b2; + }; + uint32_t outbits; + uint8_t payload[62]; + }; } hid_output_t; -void hid_proc(const uint8_t *data, uint8_t len) +void hid_proc(const uint8_t *buffer, uint8_t len) { - hid_output_t *output = (hid_output_t *)data; - if (output->report_id == REPORT_ID_OUTPUT) { - switch (output->cmd) { + hid_output_t *data = (hid_output_t *)buffer; + if (data->report_id == REPORT_ID_OUTPUT) { + switch (data->cmd) { case 0x01: // Set Timeout case 0x02: // Set Sampling Count hid_io4.system_status = 0x30; @@ -123,11 +137,23 @@ void hid_proc(const uint8_t *data, uint8_t len) hid_io4.chutes[1] = 0; hid_io4.system_status = 0x00; break; - case 0x04: // Set General Output - case 0x41: // I don't know what this is + case 0x04: // General Output + // Bit 2: QR Reader P2, + // Bit 5: QR Reader P1, + // Bit 6: Coin Blocker, + // Bit 14: Camera RECORD, + // Bit 15: Camera Ring + break; + case 0x41: // RGB Light + if (data->led != 0xfc) { + break; + } + uint32_t p1_banner = rgb32(data->r1, data->g1, data->b1, false); + rgb_set_banner(p1_banner); + // Note: p2_banner uses data->r2, data->g2, data->b2 break; default: - printf("USB unknown cmd: %d\n", output->cmd); + printf("USB unknown cmd: %d\n", data->cmd); break; } } diff --git a/firmware/src/hid.h b/firmware/src/hid.h index ea175f0..2eada91 100644 --- a/firmware/src/hid.h +++ b/firmware/src/hid.h @@ -7,6 +7,6 @@ #define HID_H_ void hid_update(); -void hid_proc(const uint8_t *data, uint8_t len); +void hid_proc(const uint8_t *buffer, uint8_t len); #endif diff --git a/firmware/src/rgb.c b/firmware/src/rgb.c index 24aa88d..8f8a4d9 100644 --- a/firmware/src/rgb.c +++ b/firmware/src/rgb.c @@ -20,7 +20,7 @@ #include "board_defs.h" #include "config.h" -#define LED_NUM 12 // 8 buttons, 3 cab, 1 aime +#define LED_NUM 13 // 8 buttons, 3 cab, 1 banner, 1 aime uint32_t rgb_buf[LED_NUM]; static struct { uint32_t color; // current color @@ -118,7 +118,14 @@ static void drive_led() last = now; for (int i = 0; i < LED_NUM; i++) { - int num = i < 8 ? mai_cfg->rgb.per_button : (i < 11 ? mai_cfg->rgb.per_cab : 16); + int num = 16; // aime light + if (i < 8) { + num = mai_cfg->rgb.per_button; + } else if (i < 11) { + num = mai_cfg->rgb.per_cab; + } else if (i < 12) { + num = mai_cfg->rgb.per_banner; + } for (int j = 0; j < num; j++) { pio_sm_put_blocking(pio0, 0, rgb_buf[i] << 8u); } @@ -201,11 +208,16 @@ void rgb_set_cab(unsigned index, uint32_t color) set_color(8 + index, color, 0); } -void rgb_set_aime(uint32_t color) +void rgb_set_banner(uint32_t color) { set_color(11, color, 0); } +void rgb_set_aime(uint32_t color) +{ + set_color(12, color, 0); +} + void rgb_init() { uint pio0_offset = pio_add_program(pio0, &ws2812_program); diff --git a/firmware/src/rgb.h b/firmware/src/rgb.h index 9dc5c40..ea96f20 100644 --- a/firmware/src/rgb.h +++ b/firmware/src/rgb.h @@ -21,6 +21,7 @@ uint32_t rgb32_from_hsv(uint8_t h, uint8_t s, uint8_t v); void rgb_set_button(unsigned index, uint32_t color, uint8_t speed); void rgb_set_cab(unsigned index, uint32_t color); +void rgb_set_banner(uint32_t color); void rgb_set_aime(uint32_t color); #endif