Compare commits

..

No commits in common. "4bd40034162410add3940c8a86d791e38fb78d28" and "60cb6e09772644dd264328f0087b3a7840bde085" have entirely different histories.

3 changed files with 167 additions and 170 deletions

View file

@ -1,11 +1,9 @@
#include <unordered_map>
#include "WiFi.h" #include "WiFi.h"
#include "AsyncUDP.h" #include "AsyncUDP.h"
#include "wifi_config.h" #include "wifi_config.h"
AsyncUDP udp; AsyncUDP udp;
char in_char = ' '; int bindex = 0;
#include "ESP32Servo.h" #include "ESP32Servo.h"
struct ServoPin { struct ServoPin {
@ -30,115 +28,115 @@ ServoPin servos[6] = {
struct BrailleChar { struct BrailleChar {
int servoStates[6]; int servoStates[6];
}; };
std::unordered_map<char, BrailleChar> brailleMap = { BrailleChar brailleAlphabet[27] = {
{'_', {{0, 0, {{0, 0,
0, 0, 0, 0,
0, 0 0, 0
}}}, }}, // _
{'a', {{1, 0, {{1, 0,
0, 0, 0, 0,
0, 0 0, 0
}}}, }}, // a
{'b', {{1, 0, {{1, 0,
1, 0, 1, 0,
0, 0 0, 0
}}}, }}, // b
{'c', {{1, 1, {{1, 1,
0, 0, 0, 0,
0, 0 0, 0
}}}, }}, // c
{'d', {{1, 1, {{1, 1,
0, 1, 0, 1,
0, 0 0, 0
}}}, }}, // d
{'e', {{1, 0, {{1, 0,
0, 1, 0, 1,
0, 0 0, 0
}}}, }}, // e
{'f', {{1, 1, {{1, 1,
1, 0, 1, 0,
0, 0 0, 0
}}}, }}, // f
{'g', {{1, 1, {{1, 1,
1, 1, 1, 1,
0, 0 0, 0
}}}, }}, // g
{'h', {{1, 0, {{1, 0,
1, 1, 1, 1,
0, 0 0, 0
}}}, }}, // h
{'i', {{0, 1, {{0, 1,
1, 0, 1, 0,
0, 0 0, 0
}}}, }}, // i
{'j', {{0, 1, {{0, 1,
1, 1, 1, 1,
0, 0 0, 0
}}}, }}, // j
{'k', {{1, 0, {{1, 0,
0, 0, 0, 0,
1, 0 1, 0
}}}, }}, // k
{'l', {{1, 0, {{1, 0,
1, 0, 1, 0,
1, 0 1, 0
}}}, }}, // l
{'m', {{1, 1, {{1, 1,
0, 0, 0, 0,
1, 0 1, 0
}}}, }}, // m
{'n', {{1, 1, {{1, 1,
0, 1, 0, 1,
1, 0 1, 0
}}}, }}, // n
{'o', {{1, 0, {{1, 0,
0, 1, 0, 1,
1, 0 1, 0
}}}, }}, // o
{'p', {{1, 1, {{1, 1,
1, 0, 1, 0,
1, 0 1, 0
}}}, }}, // p
{'q', {{1, 1, {{1, 1,
1, 1, 1, 1,
1, 0 1, 0
}}}, }}, // q
{'r', {{1, 0, {{1, 0,
1, 1, 1, 1,
1, 0 1, 0
}}}, }}, // r
{'s', {{0, 1, {{0, 1,
1, 0, 1, 0,
1, 0 1, 0
}}}, }}, // s
{'t', {{0, 1, {{0, 1,
1, 1, 1, 1,
1, 0 1, 0
}}}, }}, // t
{'u', {{1, 0, {{1, 0,
0, 0, 0, 0,
1, 1 1, 1
}}}, }}, // u
{'v', {{1, 0, {{1, 0,
1, 0, 1, 0,
1, 1 1, 1
}}}, }}, // v
{'w', {{0, 1, {{0, 1,
1, 1, 1, 1,
0, 1 0, 1
}}}, }}, // w
{'x', {{1, 1, {{1, 1,
0, 0, 0, 0,
1, 1 1, 1
}}}, }}, // x
{'y', {{1, 1, {{1, 1,
0, 1, 0, 1,
1, 1 1, 1
}}}, }}, // y
{'z', {{1, 0, {{1, 0,
0, 1, 0, 1,
1, 1 1, 1
}}} }} // z
}; };
void setup() void setup()
@ -149,7 +147,7 @@ void setup()
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass); WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
delay(1000); delay(500);
Serial.print("."); Serial.print(".");
// and print status // and print status
Serial.println(WiFi.status()); Serial.println(WiFi.status());
@ -166,9 +164,8 @@ void setup()
// so do this instead // so do this instead
// Serial.print(packet.data()[0]); // Serial.print(packet.data()[0]);
// and set the bindex to that value // and set the bindex to that value
// in_char = packet.data()[0]; bindex = packet.data()[0];
in_char = (char)packet.data()[0]; Serial.print(bindex);
Serial.print(in_char);
Serial.println(); Serial.println();
uint32_t receivedData; uint32_t receivedData;
memcpy(&receivedData, packet.data(), sizeof(receivedData)); memcpy(&receivedData, packet.data(), sizeof(receivedData));
@ -209,6 +206,6 @@ void loop()
// myservo.write(bindex); // myservo.write(bindex);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
servos[i].servo.write(brailleMap[in_char].servoStates[i] * 180); servos[i].servo.write(brailleAlphabet[bindex].servoStates[i] * 180);
} }
} }

View file

@ -28,159 +28,159 @@ public class Mono {
} }
} }
// key:(char) value:(int[] dots) // key:(string) value:(int[] dots)
Dictionary<char, int[]> char_cell = new Dictionary<char, int[]> { Dictionary<string, int[]> char_cell = new Dictionary<string, int[]> {
{ ' ', new int[] { { "a", new int[] {
0, 0,
0, 0,
0, 0
} },
{ 'a', new int[] {
1, 0, 1, 0,
0, 0, 0, 0,
0, 0 0, 0
} }, } },
{ 'b', new int[] { { "b", new int[] {
1, 0, 1, 0,
1, 0, 1, 0,
0, 0 0, 0
} }, } },
{ 'c', new int[] { { "c", new int[] {
1, 1, 1, 1,
0, 0, 0, 0,
0, 0 0, 0
} }, } },
{ 'd', new int[] { { "d", new int[] {
1, 1, 1, 1,
0, 1, 0, 1,
0, 0 0, 0
} }, } },
{ 'e', new int[] { { "e", new int[] {
1, 0, 1, 0,
0, 1, 0, 1,
0, 0 0, 0
} }, } },
{ 'f', new int[] { { "f", new int[] {
1, 1, 1, 1,
1, 0, 1, 0,
0, 0 0, 0
} }, } },
{ 'g', new int[] { { "g", new int[] {
1, 1, 1, 1,
1, 1, 1, 1,
0, 0 0, 0
} }, } },
{ 'h', new int[] { { "h", new int[] {
1, 0, 1, 0,
1, 1, 1, 1,
0, 0 0, 0
} }, } },
{ 'i', new int[] { { "i", new int[] {
0, 1, 0, 1,
1, 0, 1, 0,
0, 0 0, 0
} }, } },
{ 'j', new int[] { { "j", new int[] {
0, 1, 0, 1,
1, 1, 1, 1,
0, 0 0, 0
} }, } },
{ 'k', new int[] { { "k", new int[] {
1, 0, 1, 0,
0, 0, 0, 0,
1, 0 1, 0
} }, } },
{ 'l', new int[] { { "l", new int[] {
1, 0, 1, 0,
1, 0, 1, 0,
1, 0 1, 0
} }, } },
{ 'm', new int[] { { "m", new int[] {
1, 1, 1, 1,
0, 0, 0, 0,
1, 0 1, 0
} }, } },
{ 'n', new int[] { { "n", new int[] {
1, 1, 1, 1,
0, 1, 0, 1,
1, 0 1, 0
} }, } },
{ 'o', new int[] { { "o", new int[] {
1, 0, 1, 0,
0, 1, 0, 1,
1, 0 1, 0
} }, } },
{ 'p', new int[] { { "p", new int[] {
1, 1, 1, 1,
1, 0, 1, 0,
1, 0 1, 0
} }, } },
{ 'q', new int[] { { "q", new int[] {
1, 1, 1, 1,
1, 1, 1, 1,
1, 0 1, 0
} }, } },
{ 'r', new int[] { { "r", new int[] {
1, 0, 1, 0,
1, 1, 1, 1,
1, 0 1, 0
} }, } },
{ 's', new int[] { { "s", new int[] {
0, 1, 0, 1,
1, 0, 1, 0,
1, 0 1, 0
} }, } },
{ 't', new int[] { { "t", new int[] {
0, 1, 0, 1,
1, 1, 1, 1,
1, 0 1, 0
} }, } },
{ 'u', new int[] { { "u", new int[] {
1, 0, 1, 0,
0, 0, 0, 0,
1, 1 1, 1
} }, } },
{ 'v', new int[] { { "v", new int[] {
1, 0, 1, 0,
1, 0, 1, 0,
1, 1 1, 1
} }, } },
{ 'w', new int[] { { "w", new int[] {
0, 1, 0, 1,
1, 1, 1, 1,
0, 1 0, 1
} }, } },
{ 'x', new int[] { { "x", new int[] {
1, 1, 1, 1,
0, 0, 0, 0,
1, 1 1, 1
} }, } },
{ 'y', new int[] { { "y", new int[] {
1, 1, 1, 1,
0, 1, 0, 1,
1, 1 1, 1
} }, } },
{ 'z', new int[] { { "z", new int[] {
1, 0, 1, 0,
0, 1, 0, 1,
1, 1 1, 1
} }, } },
{ ',', new int[] { { " ", new int[] {
0, 0,
0, 0,
0, 0
} },
{ ",", new int[] {
0, 0, 0, 0,
1, 0, 1, 0,
0, 0 0, 0
} }, } },
{ '.', new int[] { { ".", new int[] {
0, 0, 0, 0,
1, 1, 1, 1,
0, 1 0, 1
} }, } },
{ '/', new int[] { { "/", new int[] {
0, 1, 0, 1,
0, 0, 0, 0,
1, 0 1, 0
} }, } },
{ ';', new int[] { { ";", new int[] {
0, 0, 0, 0,
1, 0, 1, 0,
1, 0 1, 0
@ -193,20 +193,20 @@ public class Mono {
Colemak Colemak
} }
Dictionary<Layout, char[]> layouts = new Dictionary<Layout, char[]> { Dictionary<Layout, string[]> layouts = new Dictionary<Layout, string[]> {
{ Layout.Colemak, new char[] { { Layout.Colemak, new string[] {
'q', 'w', 'f', 'p', 'g', 'j', 'l', 'u', 'y', ';', "q", "w", "f", "p", "g", "j", "l", "u", "y", ";",
'a', 'r', 's', 't', 'd', 'h', 'n', 'e', 'i', 'o', "a", "r", "s", "t", "d", "h", "n", "e", "i", "o",
'z', 'x', 'c', 'v', 'b', 'k', 'm', ',', '.', '/', "z", "x", "c", "v", "b", "k", "m", ",", ".", "/",
} }, } },
{ Layout.Qwerty, new char[] { { Layout.Qwerty, new string[] {
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', "q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', "a", "s", "d", "f", "g", "h", "j", "k", "l", ";",
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', "z", "x", "c", "v", "b", "n", "m", ",", ".", "/",
} }, } },
}; };
public char KeyToChar(int index) { public string KeyToChar(int index) {
return layouts[Layout.Colemak][index]; return layouts[Layout.Colemak][index];
} }
@ -248,7 +248,7 @@ public class Mono {
// xi = 0; // xi = 0;
// } // }
if (Input.Key(Key.Down).IsJustActive()) { if (Input.Key(Key.Down).IsJustActive()) {
monoNet.value = ' '; monoNet.value = 0;
monoNet.send = true; monoNet.send = true;
} }
@ -267,7 +267,7 @@ public class Mono {
if (index_i != last_index_i) { if (index_i != last_index_i) {
last_index_i = index_i; last_index_i = index_i;
// Log.Info($"index_i: {index_i}"); // Log.Info($"index_i: {index_i}");
monoNet.value = KeyToChar(index_i); monoNet.value = index_i;
monoNet.send = true; monoNet.send = true;
} }
} }
@ -295,10 +295,10 @@ public class Mono {
int index = y * 10 + x; int index = y * 10 + x;
// string text = characters[index].character; // string text = characters[index].character;
char keychar = KeyToChar(index); string keychar = KeyToChar(index);
Text.Add( Text.Add(
keychar.ToString(), keychar,
Matrix.TS( Matrix.TS(
pos + V.XYZ(-0.3f, -0.3f, 0), pos + V.XYZ(-0.3f, -0.3f, 0),
V.XYZ(-1, -1, 0) * 8.0f V.XYZ(-1, -1, 0) * 8.0f

View file

@ -9,13 +9,13 @@ public class MonoNet {
byte[] wData; int wHead; byte[] wData; int wHead;
public bool send = true; public bool send = true;
public char value = ' '; public int value = 0;
public MonoNet() { public MonoNet() {
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
string ip = "192.168.0.23"; string ip = "192.168.1.81";
EndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 1234); EndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 1234);
socket.Connect(serverEndPoint); socket.Connect(serverEndPoint);