-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoardSimulator.Ini
56 lines (42 loc) · 1.76 KB
/
BoardSimulator.Ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Simulate various features of the MCB 1700 board
// Written by Bernie Roehl, April 2020
FUNC unsigned int bitmask(int n) { return 1u << n; }
FUNC void ButtonDown(void) { PORT2 &= ~bitmask(10); }
FUNC void ButtonUp(void) { PORT2 |= bitmask(10); }
FUNC void AnalogValue(float f) { AIN2 = f; }
FUNC void JoystickPress(void) { PORT1 &= ~bitmask(20); }
FUNC void JoystickRelease(void) { PORT1 |= bitmask(20); }
FUNC void JoystickBit(int n) { // directions
PORT1 |= 0x0F << 23; // turn off all four bits
if (n != 0) PORT1 &= ~bitmask(n);
}
FUNC void ShowLEDs(void) {
printf("LEDs: %c%c%c%c %c%c%c%c\r\n",
(PORT2 & bitmask(6)) ? 'X' : '_',
(PORT2 & bitmask(5)) ? 'X' : '_',
(PORT2 & bitmask(4)) ? 'X' : '_',
(PORT2 & bitmask(3)) ? 'X' : '_',
(PORT2 & bitmask(2)) ? 'X' : '_',
(PORT1 & bitmask(31)) ? 'X' : '_',
(PORT1 & bitmask(29)) ? 'X' : '_',
(PORT1 & bitmask(28)) ? 'X' : '_');
}
// Button definitions
DEFINE BUTTON "Show LEDs", "ShowLEDs()"
DEFINE BUTTON "Button down", "ButtonDown()"
DEFINE BUTTON "Button up", "ButtonUp()"
DEFINE BUTTON "Joystick Press", "JoystickPress()"
DEFINE BUTTON "Joystick Release", "JoystickRelease()"
DEFINE BUTTON "Joystick North", "JoystickBit(23)"
DEFINE BUTTON "Joystick South", "JoystickBit(25)"
DEFINE BUTTON "Joystick East", "JoystickBit(24)"
DEFINE BUTTON "Joystick West", "JoystickBit(26)"
DEFINE BUTTON "Joystick Centre", "JoystickBit(0)"
DEFINE BUTTON "Analog 0.0v", "AnalogValue(0)"
DEFINE BUTTON "Analog 0.5v", "AnalogValue(0.5)"
DEFINE BUTTON "Analog 1.0v", "AnalogValue(1.0)"
DEFINE BUTTON "Analog 1.5v", "AnalogValue(1.5)"
DEFINE BUTTON "Analog 2.0v", "AnalogValue(2.0)"
DEFINE BUTTON "Analog 2.5v", "AnalogValue(2.5)"
DEFINE BUTTON "Analog 3.0v", "AnalogValue(3.0)"
DEFINE BUTTON "Analog 3.5v", "AnalogValue(3.5)"