From bdddbdd27b47f304a6cc03ae94fcfb9c918beb88 Mon Sep 17 00:00:00 2001 From: meisZWFLZ Date: Mon, 1 Jan 2024 22:06:20 -0700 Subject: [PATCH] feat: :children_crossing: add open screen method and screen enum --- src/Vex.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/VexConnection.ts | 14 +++++++++++++ src/VexPacket.ts | 5 +++-- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/Vex.ts b/src/Vex.ts index a3c458b..b3fad5e 100644 --- a/src/Vex.ts +++ b/src/Vex.ts @@ -244,3 +244,51 @@ export enum SerialDeviceType { PROLIFIC = 8963, } + +/** + * found from {@link https://gist.github.com/meisZWFLZ/9ebdd694060137b44959ff7ac80ff4e8 gist} + * @see {@link https://drive.google.com/drive/folders/11pSNKakbXp7hOYBQ3HNwprFaLalnXOgR screen images} + */ +export enum SelectDashScreen { + HOME = 0, + BATTERY = 1, + LED = 3, + MATCH_CONFIG = 4, + MATCH_CONFIG_MORE = 5, + WIRING = 6, + RADIO = 8, + BRAIN = 10, + RUN_PROGRAM = 13, + DRIVE_PROGRAM_CONTROL_LEFT_MAPPING = 14, + DRIVE_PROGRAM_MENU = 15, + DEVICES = 16, + USER_PROGRAM_FOLDER = 17, + VEX_PROGRAM_FOLDER = 18, + SETTINGS = 19, + /** theres some scary looking stuff in here */ + SCARY_CONFIGURATION = 20, + LANGUAGE = 21, + DRIVE_MOTOR_CONFIG = 22, + PROGRAM_MENU = 24, + SHUTDOWN = 25, + CONTROLLER_2_MAPPING = 26, + /** theres some even more scary looking stuff in here */ + SCARY_CONFIGURATION_MORE = 27, + /** maybe this is scarier.. */ + CONFIRM_XX = 28, + CONTROLLER_1_MAPPING = 29, + DRIVE_PROGRAM_CONTROL_DUAL_MAPPING = 30, + DRIVE_PROGRAM_CONTROL_SPLIT_MAPPING = 31, + DRIVE_PROGRAM_CONTROL_RIGHT_MAPPING = 32, + /** thats such a bad name */ + MATCH_2_4_PLAYERS = 33, + EVENT_LOG = 34, + USER_PROGRAM_WIRING = 40, + CLAWBOT_PROGRAM_MENU = 41, + /** aka regulatory */ + ABOUT = 42, + LANGUAGE_MORE = 43, + OBJECT_COLOR = 45, + SIGNATURE_ID = 46, + LOG_DATA = 47, +} diff --git a/src/VexConnection.ts b/src/VexConnection.ts index c2abf15..fd4cccb 100644 --- a/src/VexConnection.ts +++ b/src/VexConnection.ts @@ -14,6 +14,7 @@ import { type SlotNumber, USER_FLASH_USR_CODE_START, USER_PROG_CHUNK_SIZE, + type SelectDashScreen, } from "./Vex"; import { VexEventTarget } from "./VexEvent"; import { type ProgramIniConfig } from "./VexIniConfig"; @@ -51,6 +52,8 @@ import { GetDeviceStatusReplyD2HPacket, SendDashTouchH2DPacket, SendDashTouchReplyD2HPacket, + SelectDashH2DPacket, + type SelectDashReplyD2HPacket, } from "./VexPacket"; import { type VexFirmwareVersion } from "./VexFirmwareVersion"; @@ -659,6 +662,17 @@ export class V5SerialConnection extends VexSerialConnection { ); return result instanceof SendDashTouchReplyD2HPacket ? result : null; } + + /** @param port untested */ + async openScreen( + screen: number | SelectDashScreen, + port: number, + ): Promise { + const result = await this.writeDataAsync( + new SelectDashH2DPacket(screen, port), + ); + return result instanceof SendDashTouchReplyD2HPacket ? result : null; + } } function logData(data: Uint8Array, limitedSize: number): void { diff --git a/src/VexPacket.ts b/src/VexPacket.ts index fa08af9..af9281e 100644 --- a/src/VexPacket.ts +++ b/src/VexPacket.ts @@ -16,6 +16,7 @@ import { type ISmartDeviceInfo, type MatchMode, type SlotNumber, + type SelectDashScreen, } from "./Vex"; import { VexFirmwareVersion } from "./VexFirmwareVersion"; @@ -665,8 +666,8 @@ export class SelectDashH2DPacket extends DeviceBoundPacket { // UNSURE static COMMAND_ID = 86; static COMMAND_EXTENDED_ID = 43; - - constructor(screen: number, port: number) { + /** @param port untested */ + constructor(screen: number | SelectDashScreen, port: number) { const payload = new Uint8Array(2); payload[0] = screen; payload[1] = port;