2017-07-14 16:05:02 +00:00
|
|
|
#define DA A0
|
|
|
|
#define RDA A1
|
|
|
|
#define PB0 2
|
2017-07-15 15:41:20 +00:00
|
|
|
#define PB1 3
|
|
|
|
#define PB2 4
|
2017-07-14 16:05:02 +00:00
|
|
|
#define PB3 A5
|
|
|
|
#define PB4 A4
|
|
|
|
#define PB5 A3
|
|
|
|
#define PB6 A2
|
2017-07-15 16:04:16 +00:00
|
|
|
#define PA0 5
|
|
|
|
#define PA1 6
|
|
|
|
#define PA2 7
|
|
|
|
#define PA3 8
|
|
|
|
#define PA4 9
|
|
|
|
#define PA5 10
|
|
|
|
#define PA6 11
|
|
|
|
#define STROBE 12
|
2017-07-14 16:05:02 +00:00
|
|
|
|
2017-07-15 15:41:20 +00:00
|
|
|
uint8_t video_data = 0;
|
|
|
|
uint8_t video_data_pins[] = { PB0, PB1, PB2, PB3, PB4, PB5, PB6 };
|
|
|
|
uint8_t serial_data;
|
2017-07-14 16:05:02 +00:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
2017-07-15 16:04:16 +00:00
|
|
|
// Video data pins
|
2017-07-14 16:05:02 +00:00
|
|
|
pinMode(RDA, OUTPUT);
|
2017-07-15 16:04:16 +00:00
|
|
|
pinMode(DA, INPUT);
|
2017-07-14 16:05:02 +00:00
|
|
|
pinMode(PB0, INPUT);
|
|
|
|
pinMode(PB1, INPUT);
|
|
|
|
pinMode(PB2, INPUT);
|
|
|
|
pinMode(PB3, INPUT);
|
|
|
|
pinMode(PB4, INPUT);
|
|
|
|
pinMode(PB5, INPUT);
|
|
|
|
pinMode(PB6, INPUT);
|
|
|
|
|
2017-07-15 16:04:16 +00:00
|
|
|
// ASCII data pins
|
|
|
|
pinMode(STROBE, OUTPUT);
|
|
|
|
pinMode(PA0, OUTPUT);
|
|
|
|
pinMode(PA1, OUTPUT);
|
|
|
|
pinMode(PA2, OUTPUT);
|
|
|
|
pinMode(PA3, OUTPUT);
|
|
|
|
pinMode(PA4, OUTPUT);
|
|
|
|
pinMode(PA5, OUTPUT);
|
|
|
|
pinMode(PA6, OUTPUT);
|
|
|
|
|
2017-07-14 16:05:02 +00:00
|
|
|
Serial.begin(9600);
|
2017-07-15 15:41:20 +00:00
|
|
|
Serial.println("Arduino ready...");
|
2017-07-14 16:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
2017-07-15 15:41:20 +00:00
|
|
|
{
|
|
|
|
process_video_data();
|
|
|
|
process_serial_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_video_data()
|
2017-07-14 16:05:02 +00:00
|
|
|
{
|
2017-07-15 16:04:16 +00:00
|
|
|
digitalWrite(RDA, HIGH);
|
2017-07-15 15:41:20 +00:00
|
|
|
delayMicroseconds(20);
|
2017-07-14 16:05:02 +00:00
|
|
|
|
2017-07-15 16:04:16 +00:00
|
|
|
if (digitalRead(DA))
|
2017-07-14 16:05:02 +00:00
|
|
|
{
|
2017-07-15 15:41:20 +00:00
|
|
|
video_data = 0;
|
2017-07-14 16:05:02 +00:00
|
|
|
|
2017-07-15 16:04:16 +00:00
|
|
|
for (int i = 0; i < 7; i++)
|
2017-07-15 15:41:20 +00:00
|
|
|
{
|
|
|
|
if (digitalRead(video_data_pins[i]))
|
2017-07-14 16:05:02 +00:00
|
|
|
{
|
2017-07-15 15:41:20 +00:00
|
|
|
video_data |= (1 << i);
|
2017-07-14 16:05:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-15 15:41:20 +00:00
|
|
|
if (video_data == 13)
|
2017-07-14 16:05:02 +00:00
|
|
|
{
|
2017-07-15 15:41:20 +00:00
|
|
|
Serial.println();
|
|
|
|
}
|
|
|
|
else if (video_data > 31)
|
|
|
|
{
|
|
|
|
Serial.print((char)video_data);
|
2017-07-14 16:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
digitalWrite(RDA, LOW);
|
2017-07-15 15:41:20 +00:00
|
|
|
delayMicroseconds(20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_serial_data()
|
|
|
|
{
|
|
|
|
if (Serial.available() > 0)
|
|
|
|
{
|
|
|
|
serial_data = Serial.read();
|
|
|
|
|
2017-07-15 16:04:16 +00:00
|
|
|
if (serial_data == 203) // Uppercase ESC
|
|
|
|
{
|
|
|
|
serial_data = 27;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serial_data >= 97 && serial_data <= 122) // lower case a-z
|
|
|
|
{
|
|
|
|
serial_data -= 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serial_data < 96) // Is the character Apple 1 compatible?
|
|
|
|
{
|
|
|
|
digitalWrite(PA6, bitRead(serial_data, 6));
|
|
|
|
digitalWrite(PA5, bitRead(serial_data, 5));
|
|
|
|
digitalWrite(PA4, bitRead(serial_data, 4));
|
|
|
|
digitalWrite(PA3, bitRead(serial_data, 3));
|
|
|
|
digitalWrite(PA2, bitRead(serial_data, 2));
|
|
|
|
digitalWrite(PA1, bitRead(serial_data, 1));
|
|
|
|
digitalWrite(PA0, bitRead(serial_data, 0));
|
|
|
|
|
|
|
|
digitalWrite(STROBE, HIGH);
|
|
|
|
delayMicroseconds(20);
|
|
|
|
digitalWrite(STROBE, LOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2017-07-15 15:41:20 +00:00
|
|
|
if (serial_data == 13)
|
|
|
|
{
|
|
|
|
Serial.println();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Serial.print((char)serial_data);
|
|
|
|
}
|
2017-07-15 16:04:16 +00:00
|
|
|
*/
|
2017-07-14 16:05:02 +00:00
|
|
|
}
|
|
|
|
}
|