Skip to content

Commit

Permalink
feat: 🚸 add open screen method and screen enum
Browse files Browse the repository at this point in the history
  • Loading branch information
meisZWFLZ committed Jan 2, 2024
1 parent 01ef415 commit bdddbdd
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
48 changes: 48 additions & 0 deletions src/Vex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
14 changes: 14 additions & 0 deletions src/VexConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -51,6 +52,8 @@ import {
GetDeviceStatusReplyD2HPacket,
SendDashTouchH2DPacket,
SendDashTouchReplyD2HPacket,
SelectDashH2DPacket,
type SelectDashReplyD2HPacket,
} from "./VexPacket";
import { type VexFirmwareVersion } from "./VexFirmwareVersion";

Expand Down Expand Up @@ -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<SelectDashReplyD2HPacket | null> {
const result = await this.writeDataAsync(
new SelectDashH2DPacket(screen, port),
);
return result instanceof SendDashTouchReplyD2HPacket ? result : null;
}
}

function logData(data: Uint8Array, limitedSize: number): void {
Expand Down
5 changes: 3 additions & 2 deletions src/VexPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type ISmartDeviceInfo,
type MatchMode,
type SlotNumber,
type SelectDashScreen,
} from "./Vex";
import { VexFirmwareVersion } from "./VexFirmwareVersion";

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bdddbdd

Please sign in to comment.