diff --git a/apple2idiot.ino b/apple2idiot.ino index 9a680af..0ce4afc 100644 --- a/apple2idiot.ino +++ b/apple2idiot.ino @@ -20,26 +20,34 @@ blah blah blah #define D1R 13 #define D2R 14 #define D3R 15 -#define D4R 18 -#define D5R 19 -#define D6R 21 -#define D7R 22 +#define D4R 16 +#define D5R 17 +#define D6R 18 +#define D7R 19 byte data_pins[] = {D0R, D1R, D2R, D3R, D4R, D5R, D6R, D7R}; #define DATA_BUS_SIZE 8 /* Address Bus */ -#define A0R 23 -#define A1R 25 -#define A2R 26 -#define A3R 27 -byte address_pins[] = {A0R, A1R, A2R, A3R}; -#define ADDRESS_BUS_SIZE 4 +#define A0R 21 +#define A1R 22 +#define A2R 23 +#define A3R 25 +#define A4R 26 +#define A5R 27 +#define A6R 32 +#define A7R 33 +byte address_pins[] = {A0R, A1R, A2R, A3R, A4R, A5R, A6R, A7R}; +/* #define ADDRESS_BUS_SIZE 4 */ +#define ADDRESS_BUS_SIZE 8 /* IDT7132S dual port ram chip enable */ #define RW_PIN 5 #define RW_WRITE LOW #define RW_READ HIGH +#define INPUT_35 35 +#define INPUT_34 34 + unsigned int data_byte = 0; // fisrt bit is a flag for if the data is from Apple or from ESP32. // / @@ -71,7 +79,9 @@ volatile uint16_t raw_register1_read; /**********************/ // Replace with your network credentials -const char* wifi_ssid = "GSO"; +//const char* wifi_ssid = "GSO"; +//const char* wifi_password = "xerxes27"; +const char* wifi_ssid = "Pixel_8985"; const char* wifi_password = "xerxes27"; AsyncWebServer web_server(80); //WebServer web_server(80); @@ -90,7 +100,8 @@ const String weather_url = "http://api.openweathermap.org/data/2.5/weather?"; const long readLoopInterval = 10000; // millis unsigned long lastReadLoopTime = 0; //byte ram[ADDRESS_BUS_SIZE]; -byte ram[16]; +//byte ram[256]; +byte ram[256]; volatile byte ram_busy=0; //const unsigned int RAM_BUSY=666; #define RAM_BUSY 666 @@ -121,9 +132,10 @@ boolean set_address(int address) { //delay(20); Serial.print(" A:"); for (byte i=0; i0; i--) { byte state = bitRead(address, i); - digitalWrite(address_pins[i], state); - Serial.print(state); + digitalWrite(address_pins[i], !state); + Serial.print(!state); } Serial.println(); return true; @@ -184,7 +196,8 @@ boolean write_data(byte address, byte byte_to_write) { void store_ip_to_ram(byte offset) { IPAddress ip_address = WiFi.localIP(); - for (int i=0; i < ADDRESS_BUS_SIZE; i++) { + //for (int i=0; i < ADDRESS_BUS_SIZE; i++) { + for (int i=0; i < 4; i++) { write_data(i+offset, ip_address[i]); } } @@ -258,7 +271,8 @@ void fetch_weather(char* city_name) { } void read_ram() { - for (int i=0; i < 16; i++) { + //for (int i=0; i < 16; i++) { + for (int i=0; i < 256; i++) { unsigned int foo = read_data(i); ram[i] = foo; } @@ -269,7 +283,8 @@ String html_template_processor(const String& var) { String return_string = ""; if (var == "RAM_TABLE") { read_ram(); - for (int i=0; i < 16; i++) { + //for (int i=0; i < 16; i++) { + for (int i=0; i < 256; i++) { return_string += ""+String(i)+"" + String(ram[i]) + "\n"; } return return_string; @@ -337,6 +352,10 @@ void setup() { pinMode(A1R, OUTPUT); digitalWrite(A1R, LOW); pinMode(A2R, OUTPUT); digitalWrite(A2R, LOW); pinMode(A3R, OUTPUT); digitalWrite(A3R, LOW); + pinMode(A4R, OUTPUT); digitalWrite(A4R, LOW); + pinMode(A5R, OUTPUT); digitalWrite(A5R, LOW); + pinMode(A6R, OUTPUT); digitalWrite(A6R, LOW); + pinMode(A7R, OUTPUT); digitalWrite(A7R, LOW); pinMode(D0R, INPUT); pinMode(D1R, INPUT); pinMode(D2R, INPUT); @@ -347,6 +366,9 @@ void setup() { pinMode(D7R, INPUT); pinMode(RW_PIN, OUTPUT); digitalWrite(RW_PIN, RW_READ); + pinMode(INPUT_34, INPUT); + pinMode(INPUT_35, INPUT); + delay(10); //wifi_scan(); diff --git a/card/apple2idiot_new/_autosave-apple2idiot_new.sch b/card/apple2idiot_new/_autosave-apple2idiot_new.sch new file mode 100644 index 0000000..3ca5231 --- /dev/null +++ b/card/apple2idiot_new/_autosave-apple2idiot_new.sch @@ -0,0 +1,898 @@ +EESchema Schematic File Version 4 +EELAYER 30 0 +EELAYER END +$Descr B 17000 11000 +encoding utf-8 +Sheet 1 1 +Title "Apple2Idiot" +Date "2021-08-06" +Rev "1" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "Nathanial Hendler" +$EndDescr +$Comp +L apple2idiot_new-rescue:AppleIIBus-kicad-library J1 +U 1 1 61291E51 +P 3400 6800 +F 0 "J1" H 3950 8300 50 0000 C CNN +F 1 "AppleIIBus" H 3800 5300 50 0000 C CNN +F 2 "kicad-library:AppleIIBus" H 3400 6800 50 0001 C CNN +F 3 "" H 3400 6800 50 0001 C CNN + 1 3400 6800 + 1 0 0 -1 +$EndComp +$Comp +L apple2idiot_new-rescue:ESP32-DEVKITC-32D-ESP32-DEV_KIT U2 +U 1 1 612B5485 +P 13000 5550 +F 0 "U2" H 13500 6600 50 0000 C CNN +F 1 "ESP32-DEVKITC-32D" H 13200 4500 50 0000 C CNN +F 2 "MODULE_ESP32-DEVKITC-32D" H 13000 5550 50 0001 L BNN +F 3 "" H 13000 5550 50 0001 L BNN +F 4 "4" H 13000 5550 50 0001 L BNN "PARTREV" +F 5 "Espressif Systems" H 13000 5550 50 0001 L BNN "MANUFACTURER" + 1 13000 5550 + 1 0 0 -1 +$EndComp +Text GLabel 11950 6450 0 50 Input ~ 0 +VCC +Text GLabel 3250 5200 1 50 Input ~ 0 +VCC +Wire Wire Line + 11950 6450 12200 6450 +Text GLabel 14050 4650 2 50 Input ~ 0 +GND +Text GLabel 14050 5250 2 50 Input ~ 0 +GND +Text GLabel 3400 8500 3 50 Input ~ 0 +GND +Wire Wire Line + 3400 8350 3400 8500 +Wire Wire Line + 13800 4650 14050 4650 +Wire Wire Line + 13800 5250 14050 5250 +Entry Wire Line + 2500 6300 2400 6200 +Entry Wire Line + 2400 6100 2500 6200 +Entry Wire Line + 2400 6000 2500 6100 +Entry Wire Line + 2400 5900 2500 6000 +Entry Wire Line + 2400 5800 2500 5900 +Entry Wire Line + 2400 5700 2500 5800 +Entry Wire Line + 2400 5600 2500 5700 +Entry Wire Line + 2400 5500 2500 5600 +Entry Wire Line + 2400 5400 2500 5500 +Wire Wire Line + 2500 5500 2700 5500 +Wire Wire Line + 2500 5600 2700 5600 +Wire Wire Line + 2500 5700 2700 5700 +Wire Wire Line + 2500 5800 2700 5800 +Wire Wire Line + 2500 5900 2700 5900 +Wire Wire Line + 2500 6000 2700 6000 +Wire Wire Line + 2500 6100 2700 6100 +Wire Wire Line + 2500 6200 2700 6200 +Wire Wire Line + 2500 6300 2700 6300 +Entry Wire Line + 7400 6050 7300 5950 +Entry Wire Line + 7300 5850 7400 5950 +Entry Wire Line + 7300 5750 7400 5850 +Entry Wire Line + 7300 5650 7400 5750 +Entry Wire Line + 7300 5550 7400 5650 +Entry Wire Line + 7300 5450 7400 5550 +Entry Wire Line + 7300 5350 7400 5450 +Entry Wire Line + 7300 5250 7400 5350 +Entry Wire Line + 7300 5150 7400 5250 +Wire Wire Line + 7400 5250 7600 5250 +Wire Wire Line + 7400 5350 7600 5350 +Wire Wire Line + 7400 5450 7600 5450 +Wire Wire Line + 7400 5550 7600 5550 +Wire Wire Line + 7400 5650 7600 5650 +Wire Wire Line + 7400 5750 7600 5750 +Wire Wire Line + 7400 5850 7600 5850 +Wire Wire Line + 7400 5950 7600 5950 +Wire Wire Line + 7400 6050 7600 6050 +Entry Wire Line + 4250 6250 4350 6350 +Entry Wire Line + 4250 6150 4350 6250 +Entry Wire Line + 4250 6050 4350 6150 +Entry Wire Line + 4250 5950 4350 6050 +Entry Wire Line + 4250 5850 4350 5950 +Entry Wire Line + 4250 5750 4350 5850 +Entry Wire Line + 4250 5650 4350 5750 +Entry Wire Line + 4250 5550 4350 5650 +Entry Wire Line + 7400 6150 7300 6050 +Wire Wire Line + 7400 6150 7600 6150 +Entry Wire Line + 2500 6500 2400 6400 +Entry Wire Line + 2400 6300 2500 6400 +Wire Wire Line + 2500 6400 2700 6400 +Wire Wire Line + 2500 6500 2700 6500 +Entry Wire Line + 9600 5350 9700 5450 +Entry Wire Line + 9600 5450 9700 5550 +Entry Wire Line + 9600 5250 9700 5350 +Entry Wire Line + 11200 5750 11300 5850 +Entry Wire Line + 11200 5950 11300 6050 +Entry Wire Line + 11200 5650 11300 5750 +Wire Wire Line + 9600 5250 9400 5250 +Wire Wire Line + 9600 5350 9400 5350 +Wire Wire Line + 9600 5450 9400 5450 +Text GLabel 11950 5950 0 50 Input ~ 0 +GND +Wire Wire Line + 11950 5950 12200 5950 +Wire Wire Line + 11300 6050 12200 6050 +Wire Wire Line + 11300 5850 12200 5850 +Entry Wire Line + 9600 5550 9700 5650 +Wire Wire Line + 9600 5550 9400 5550 +Entry Wire Line + 14550 6150 14650 6250 +Entry Wire Line + 14550 5750 14650 5850 +Entry Wire Line + 14550 5650 14650 5750 +Entry Wire Line + 14550 5450 14650 5550 +Entry Wire Line + 14550 5350 14650 5450 +Wire Wire Line + 13800 6150 14550 6150 +Wire Wire Line + 13800 5750 14550 5750 +Wire Wire Line + 13800 5650 14550 5650 +Wire Wire Line + 13800 5450 14550 5450 +Wire Wire Line + 13800 5350 14550 5350 +Entry Wire Line + 9600 6550 9700 6650 +Entry Wire Line + 9600 6650 9700 6750 +Wire Wire Line + 9600 6550 9400 6550 +Wire Wire Line + 9600 6650 9400 6650 +Entry Wire Line + 9600 6850 9700 6950 +Entry Wire Line + 9600 6950 9700 7050 +Entry Wire Line + 9600 6750 9700 6850 +Wire Wire Line + 9600 6750 9400 6750 +Wire Wire Line + 9600 6850 9400 6850 +Wire Wire Line + 9600 6950 9400 6950 +Entry Wire Line + 9600 7150 9700 7250 +Entry Wire Line + 9600 7050 9700 7150 +Wire Wire Line + 9600 7050 9400 7050 +Wire Wire Line + 9600 7150 9400 7150 +Entry Wire Line + 7400 6950 7300 6850 +Entry Wire Line + 7300 6750 7400 6850 +Entry Wire Line + 7300 6650 7400 6750 +Entry Wire Line + 7300 6550 7400 6650 +Wire Wire Line + 7400 6550 7600 6550 +Wire Wire Line + 7400 6650 7600 6650 +Wire Wire Line + 7400 6750 7600 6750 +Wire Wire Line + 7400 6850 7600 6850 +Wire Wire Line + 7400 6950 7600 6950 +Entry Wire Line + 7400 7050 7300 6950 +Wire Wire Line + 7400 7050 7600 7050 +Entry Wire Line + 7400 7150 7300 7050 +Wire Wire Line + 7400 7150 7600 7150 +Wire Bus Line + 11200 7550 9700 7550 +Wire Bus Line + 11200 7550 14650 7550 +Connection ~ 11200 7550 +Text GLabel 9650 4750 2 50 Input ~ 0 +GND +Wire Wire Line + 9400 4750 9650 4750 +Text GLabel 9650 4850 2 50 Input ~ 0 +RWR +Wire Wire Line + 9400 4850 9650 4850 +Text GLabel 14050 5550 2 50 Input ~ 0 +RWR +Wire Wire Line + 13800 5550 14050 5550 +Entry Wire Line + 14550 5150 14650 5250 +Wire Wire Line + 13800 5150 14550 5150 +Entry Wire Line + 14550 4850 14650 4950 +Wire Wire Line + 13800 4850 14550 4850 +Entry Wire Line + 14550 4750 14650 4850 +Wire Wire Line + 13800 4750 14550 4750 +Wire Wire Line + 11300 5750 12200 5750 +Entry Wire Line + 11200 5350 11300 5450 +Wire Wire Line + 11300 5450 12200 5450 +Wire Bus Line + 9700 5350 11200 5350 +Wire Bus Line + 11200 5350 11200 4100 +Wire Bus Line + 11200 4100 14650 4100 +Wire Wire Line + 3250 5250 3250 5200 +Wire Wire Line + 4100 5550 4250 5550 +Wire Wire Line + 4100 5650 4250 5650 +Wire Wire Line + 4100 5750 4250 5750 +Wire Wire Line + 4100 5850 4250 5850 +Wire Wire Line + 4100 5950 4250 5950 +Wire Wire Line + 4100 6050 4250 6050 +Wire Wire Line + 4100 6150 4250 6150 +Wire Wire Line + 4100 6250 4250 6250 +Wire Wire Line + 2700 7200 2100 7200 +Wire Wire Line + 2100 7200 2100 3700 +Wire Wire Line + 7600 4950 7450 4950 +Wire Wire Line + 8050 4200 9900 4200 +Wire Wire Line + 9900 4200 9900 4950 +Wire Wire Line + 9900 4950 9400 4950 +Wire Wire Line + 12200 5150 11950 5150 +Wire Wire Line + 2700 7500 1950 7500 +Wire Wire Line + 1950 7500 1950 4850 +Wire Wire Line + 2100 3700 2750 3700 +Text Label 2500 5500 0 50 ~ 0 +A0 +Text Label 2500 5600 0 50 ~ 0 +A1 +Text Label 2500 5700 0 50 ~ 0 +A2 +Text Label 2500 5800 0 50 ~ 0 +A3 +Text Label 2500 5900 0 50 ~ 0 +A4 +Text Label 2500 6000 0 50 ~ 0 +A5 +Text Label 2500 6100 0 50 ~ 0 +A6 +Text Label 2500 6200 0 50 ~ 0 +A7 +Text Label 2500 6300 0 50 ~ 0 +A8 +Text Label 2500 6400 0 50 ~ 0 +A9 +Text Label 2500 6500 0 50 ~ 0 +A10 +Text Label 4150 5550 0 50 ~ 0 +D0 +Text Label 4150 5650 0 50 ~ 0 +D1 +Text Label 4150 5750 0 50 ~ 0 +D2 +Text Label 4150 5850 0 50 ~ 0 +D3 +Text Label 4150 5950 0 50 ~ 0 +D4 +Text Label 4150 6050 0 50 ~ 0 +D5 +Text Label 4150 6150 0 50 ~ 0 +D6 +Text Label 4150 6250 0 50 ~ 0 +D7 +Text Label 7400 6550 0 50 ~ 0 +D1 +Text Label 7400 6650 0 50 ~ 0 +D2 +Text Label 7400 6750 0 50 ~ 0 +D3 +Text Label 7400 6850 0 50 ~ 0 +D4 +Text Label 7400 6950 0 50 ~ 0 +D5 +Text Label 7400 7050 0 50 ~ 0 +D6 +Text Label 7400 7150 0 50 ~ 0 +D7 +Text Label 7400 5250 0 50 ~ 0 +A0 +Text Label 7400 5350 0 50 ~ 0 +A1 +Text Label 7400 5450 0 50 ~ 0 +A2 +Text Label 7400 5550 0 50 ~ 0 +A3 +Text Label 7400 5650 0 50 ~ 0 +A4 +Text Label 7400 5750 0 50 ~ 0 +A5 +Text Label 7400 5850 0 50 ~ 0 +A6 +Text Label 7400 5950 0 50 ~ 0 +A7 +Text Label 7400 6050 0 50 ~ 0 +A8 +Text Label 7400 6150 0 50 ~ 0 +A9 +Text Label 9450 5250 0 50 ~ 0 +AR0 +Text Label 9450 5350 0 50 ~ 0 +AR1 +Text Label 9450 5450 0 50 ~ 0 +AR2 +Text Label 9450 5550 0 50 ~ 0 +AR3 +Text Label 14350 5150 0 50 ~ 0 +AR0 +Text Label 14350 4850 0 50 ~ 0 +AR1 +Text Label 14350 4750 0 50 ~ 0 +AR2 +Text Label 11400 5450 0 50 ~ 0 +AR3 +Text Label 9400 6550 0 50 ~ 0 +DR1 +Text Label 9400 6650 0 50 ~ 0 +DR2 +Text Label 9400 6750 0 50 ~ 0 +DR3 +Text Label 9400 6850 0 50 ~ 0 +DR4 +Text Label 9400 6950 0 50 ~ 0 +DR5 +Text Label 9400 7050 0 50 ~ 0 +DR6 +Text Label 9400 7150 0 50 ~ 0 +DR7 +Text Label 11350 5850 0 50 ~ 0 +DR0 +Text Label 11350 6050 0 50 ~ 0 +DR1 +Text Label 11350 5750 0 50 ~ 0 +DR2 +Text Label 14350 6150 0 50 ~ 0 +DR3 +Text Label 14350 5750 0 50 ~ 0 +DR4 +Text Label 14350 5650 0 50 ~ 0 +DR5 +Text Label 14350 5450 0 50 ~ 0 +DR6 +Text Label 14350 5350 0 50 ~ 0 +DR7 +$Comp +L Connector_Generic:Conn_02x02_Odd_Even J2 +U 1 1 615F9C72 +P 2950 3700 +F 0 "J2" H 3000 3917 50 0000 C CNN +F 1 "Conn_02x02_Odd_Even" H 3000 3826 50 0000 C CNN +F 2 "Connector_PinHeader_2.54mm:PinHeader_2x02_P2.54mm_Vertical" H 2950 3700 50 0001 C CNN +F 3 "~" H 2950 3700 50 0001 C CNN + 1 2950 3700 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1850 3800 2750 3800 +Wire Wire Line + 1850 7400 2700 7400 +Wire Wire Line + 3250 3700 3250 3800 +Wire Wire Line + 1950 4850 7600 4850 +Wire Wire Line + 3250 3800 7200 3800 +Wire Wire Line + 7200 3800 7200 4750 +Connection ~ 3250 3800 +Wire Wire Line + 7200 4750 7600 4750 +$Comp +L Connector_Generic:Conn_02x04_Odd_Even J5 +U 1 1 61627517 +P 10300 5750 +F 0 "J5" H 10350 6067 50 0000 C CNN +F 1 "Conn_02x02_Odd_Even" H 10350 5976 50 0000 C CNN +F 2 "Connector_PinHeader_2.54mm:PinHeader_2x04_P2.54mm_Vertical" H 10300 5750 50 0001 C CNN +F 3 "~" H 10300 5750 50 0001 C CNN + 1 10300 5750 + 1 0 0 -1 +$EndComp +Wire Wire Line + 9650 5650 9650 5700 +Wire Wire Line + 9650 5700 9750 5700 +Wire Wire Line + 9750 5700 9750 5650 +Wire Wire Line + 9750 5650 10100 5650 +Wire Wire Line + 9400 5650 9650 5650 +Wire Wire Line + 9400 5750 10100 5750 +Wire Wire Line + 10600 5650 10800 5650 +Wire Wire Line + 10800 5650 10800 5550 +Wire Wire Line + 10800 5550 12200 5550 +Wire Wire Line + 10600 5750 10650 5750 +Wire Wire Line + 10850 5750 10850 5600 +Wire Wire Line + 10850 5600 12000 5600 +Wire Wire Line + 12000 5600 12000 5650 +Wire Wire Line + 12000 5650 12200 5650 +Wire Wire Line + 9400 5850 10100 5850 +Wire Wire Line + 9400 5950 10100 5950 +Wire Wire Line + 10600 5850 10700 5850 +Wire Wire Line + 10900 5850 10900 5250 +Wire Wire Line + 10900 5250 12200 5250 +Wire Wire Line + 10600 5950 10750 5950 +Wire Wire Line + 11000 5950 11000 5300 +Wire Wire Line + 11000 5300 12050 5300 +Wire Wire Line + 12050 5300 12050 5350 +Wire Wire Line + 12050 5350 12200 5350 +$Comp +L Connector_Generic:Conn_02x07_Odd_Even J6 +U 1 1 6166C407 +P 12450 2400 +F 0 "J6" H 12500 2917 50 0000 C CNN +F 1 "Conn_02x07_Odd_Even" H 12500 2826 50 0000 C CNN +F 2 "Connector_PinSocket_2.54mm:PinSocket_2x07_P2.54mm_Vertical" H 12450 2400 50 0001 C CNN +F 3 "~" H 12450 2400 50 0001 C CNN + 1 12450 2400 + 1 0 0 -1 +$EndComp +Connection ~ 10600 5650 +Connection ~ 10650 5750 +Wire Wire Line + 10650 5750 10850 5750 +Connection ~ 10700 5850 +Wire Wire Line + 10700 5850 10900 5850 +Connection ~ 10750 5950 +Wire Wire Line + 10750 5950 11000 5950 +Wire Wire Line + 12250 2100 10600 2100 +Wire Wire Line + 10600 2100 10600 5650 +Wire Wire Line + 12250 2200 10650 2200 +Wire Wire Line + 10650 2200 10650 5750 +Wire Wire Line + 12250 2300 10700 2300 +Wire Wire Line + 10700 2300 10700 5850 +Wire Wire Line + 12250 2400 10750 2400 +Wire Wire Line + 10750 2400 10750 5950 +Wire Wire Line + 12000 5050 12000 2500 +Wire Wire Line + 12000 2500 12250 2500 +Wire Wire Line + 12000 5050 12200 5050 +Wire Wire Line + 11950 5150 11950 2600 +Wire Wire Line + 11950 2600 12250 2600 +Wire Wire Line + 12200 4850 12100 4850 +Wire Wire Line + 12100 4850 12100 2850 +Wire Wire Line + 12100 2850 12850 2850 +Wire Wire Line + 12850 2850 12850 2700 +Wire Wire Line + 12850 2700 12750 2700 +Wire Wire Line + 12200 4950 12050 4950 +Wire Wire Line + 12050 4950 12050 2700 +Wire Wire Line + 12050 2700 12250 2700 +Wire Wire Line + 13800 6050 16050 6050 +Wire Wire Line + 16050 6050 16050 2100 +Wire Wire Line + 16050 2100 12750 2100 +Wire Wire Line + 13800 5950 15950 5950 +Wire Wire Line + 15950 5950 15950 2200 +Wire Wire Line + 15950 2200 12750 2200 +Wire Wire Line + 14550 5850 14550 5900 +Wire Wire Line + 14800 5900 14800 5850 +Wire Wire Line + 14800 5850 15850 5850 +Wire Wire Line + 15850 5850 15850 2300 +Wire Wire Line + 15850 2300 12750 2300 +Wire Wire Line + 13800 5850 14550 5850 +Wire Wire Line + 14550 5900 14800 5900 +Wire Wire Line + 13800 5050 14550 5050 +Wire Wire Line + 14550 5050 14550 5100 +Wire Wire Line + 14550 5100 15750 5100 +Wire Wire Line + 15750 2400 12750 2400 +Wire Wire Line + 15750 2400 15750 5100 +Wire Wire Line + 13800 4950 14550 4950 +Wire Wire Line + 14550 4950 14550 5000 +Wire Wire Line + 14550 5000 15650 5000 +Wire Wire Line + 15650 2500 12750 2500 +Wire Wire Line + 15650 2500 15650 5000 +$Comp +L Connector_Generic:Conn_02x02_Odd_Even J4 +U 1 1 61709865 +P 8400 2800 +F 0 "J4" H 8450 3017 50 0000 C CNN +F 1 "Conn_02x02_Odd_Even" H 8450 2926 50 0000 C CNN +F 2 "Connector_PinHeader_2.54mm:PinHeader_2x02_P2.54mm_Vertical" H 8400 2800 50 0001 C CNN +F 3 "~" H 8400 2800 50 0001 C CNN + 1 8400 2800 + 1 0 0 -1 +$EndComp +Wire Wire Line + 7450 4950 7450 2800 +Wire Wire Line + 7450 2800 8200 2800 +Wire Wire Line + 8050 2900 8200 2900 +Wire Wire Line + 8050 2900 8050 4200 +Wire Wire Line + 8700 2800 11600 2800 +Wire Wire Line + 11600 2800 11600 5050 +Wire Wire Line + 11600 5050 12000 5050 +Connection ~ 12000 5050 +Wire Wire Line + 8700 2900 11500 2900 +Wire Wire Line + 11500 2900 11500 5150 +Wire Wire Line + 11500 5150 11950 5150 +Connection ~ 11950 5150 +$Comp +L Device:C C1 +U 1 1 6174221E +P 5250 8150 +F 0 "C1" H 5365 8196 50 0000 L CNN +F 1 "C" H 5365 8105 50 0000 L CNN +F 2 "Capacitor_THT:C_Disc_D10.5mm_W5.0mm_P10.00mm" H 5288 8000 50 0001 C CNN +F 3 "~" H 5250 8150 50 0001 C CNN + 1 5250 8150 + 1 0 0 -1 +$EndComp +Text GLabel 5250 8400 3 50 Input ~ 0 +GND +Text GLabel 5250 7900 1 50 Input ~ 0 +VCC +Wire Wire Line + 5250 7900 5250 8000 +Wire Wire Line + 5250 8300 5250 8400 +Wire Bus Line + 2400 4950 7300 4950 +Wire Wire Line + 1850 2200 5000 2200 +Wire Wire Line + 5000 2200 5000 1850 +Wire Wire Line + 1850 2200 1850 3800 +Connection ~ 1850 3800 +Wire Wire Line + 1850 3800 1850 7400 +Wire Wire Line + 2100 3700 2100 2300 +Wire Wire Line + 2100 2300 5100 2300 +Wire Wire Line + 5100 2300 5100 1850 +Connection ~ 2100 3700 +Wire Wire Line + 8050 2900 5300 2900 +Wire Wire Line + 5300 2900 5300 1850 +Connection ~ 8050 2900 +Wire Wire Line + 7450 2800 5200 2800 +Wire Wire Line + 5200 2800 5200 1850 +Connection ~ 7450 2800 +Text GLabel 7550 5050 0 50 Input ~ 0 +GND +Wire Wire Line + 7550 5050 7600 5050 +Text GLabel 9450 5050 2 50 Input ~ 0 +GND +Wire Wire Line + 9450 5050 9400 5050 +Text GLabel 9450 6050 2 50 Input ~ 0 +GND +Wire Wire Line + 9450 6050 9400 6050 +Text GLabel 9450 6150 2 50 Input ~ 0 +GND +Wire Wire Line + 9450 6150 9400 6150 +$Comp +L Connector_Generic:Conn_01x04 J3 +U 1 1 618300D7 +P 5100 1650 +F 0 "J3" V 5064 1362 50 0000 R CNN +F 1 "Conn_01x04" V 4973 1362 50 0000 R CNN +F 2 "Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_Vertical" H 5100 1650 50 0001 C CNN +F 3 "~" H 5100 1650 50 0001 C CNN + 1 5100 1650 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 9450 6250 9400 6250 +Text GLabel 9450 6250 2 50 Input ~ 0 +GND +Text Label 9400 6450 0 50 ~ 0 +DR0 +Text Label 7400 6250 0 50 ~ 0 +A10 +Text Label 7400 6450 0 50 ~ 0 +D0 +Wire Bus Line + 4350 6350 7300 6350 +Wire Wire Line + 7400 6450 7600 6450 +Entry Wire Line + 7300 6350 7400 6450 +Entry Wire Line + 7300 6450 7400 6550 +Wire Wire Line + 9600 6450 9400 6450 +Entry Wire Line + 9600 6450 9700 6550 +Wire Wire Line + 7400 6250 7600 6250 +Entry Wire Line + 7400 6250 7300 6150 +$Comp +L Memory_RAM:IDT7132 U1 +U 1 1 61296796 +P 8500 5950 +F 0 "U1" H 9050 7400 50 0000 C CNN +F 1 "IDT7132" H 8950 4500 50 0000 C CNN +F 2 "Package_DIP:DIP-48_W15.24mm_LongPads" H 8500 5950 50 0001 C CNN +F 3 "" H 8500 5950 50 0001 C CNN + 1 8500 5950 + 1 0 0 -1 +$EndComp +NoConn ~ 12750 2600 +NoConn ~ 4100 6450 +NoConn ~ 4100 6550 +NoConn ~ 4100 6650 +NoConn ~ 4100 6750 +NoConn ~ 4100 6950 +NoConn ~ 4100 7050 +NoConn ~ 4100 7150 +NoConn ~ 4100 7350 +NoConn ~ 4100 7450 +NoConn ~ 4100 7550 +NoConn ~ 4100 7650 +NoConn ~ 4100 7850 +NoConn ~ 4100 8050 +NoConn ~ 2700 8100 +NoConn ~ 2700 7900 +NoConn ~ 2700 7800 +NoConn ~ 2700 7700 +NoConn ~ 2700 6600 +NoConn ~ 2700 6700 +NoConn ~ 2700 6800 +NoConn ~ 2700 6900 +NoConn ~ 2700 7000 +NoConn ~ 2700 7300 +NoConn ~ 3350 5250 +NoConn ~ 3450 5250 +NoConn ~ 3550 5250 +NoConn ~ 12200 6150 +NoConn ~ 12200 6250 +NoConn ~ 12200 6350 +NoConn ~ 13800 6250 +NoConn ~ 13800 6350 +NoConn ~ 13800 6450 +NoConn ~ 12200 4650 +NoConn ~ 12200 4750 +Text Label 12050 5550 0 50 ~ 0 +IO26 +Text Label 12050 5650 0 50 ~ 0 +IO27 +Text Label 12050 5350 0 50 ~ 0 +IO33 +Text Label 12050 5450 0 50 ~ 0 +IO25 +Text Label 12050 5050 0 50 ~ 0 +IO34 +Text Label 12050 5150 0 50 ~ 0 +IO35 +Text Label 12050 5250 0 50 ~ 0 +IO32 +Text Label 12100 4850 0 50 ~ 0 +SENVP +Text Label 12100 4950 0 50 ~ 0 +SENVN +Text Label 13800 4950 0 50 ~ 0 +TX +Text Label 13800 5050 0 50 ~ 0 +RX +Text Label 13850 5850 0 50 ~ 0 +IO4 +Text Label 13850 5950 0 50 ~ 0 +IO0 +Text Label 13850 6050 0 50 ~ 0 +IO2 +Text Label 9400 5650 0 50 ~ 0 +AR4 +Text Label 9400 5750 0 50 ~ 0 +AR5 +Text Label 9400 5850 0 50 ~ 0 +AR6 +Text Label 9400 5950 0 50 ~ 0 +AR7 +Text Label 7500 4950 0 50 ~ 0 +BSYL +Text Label 9350 4950 0 50 ~ 0 +BSYR +Text Label 2250 7200 0 50 ~ 0 +IOSEL +Text Label 2250 7400 0 50 ~ 0 +DEVSEL +Text Label 2250 7500 0 50 ~ 0 +RW +Text Label 3450 3800 0 50 ~ 0 +CEL +Wire Bus Line + 9700 5350 9700 5650 +Wire Bus Line + 11200 5650 11200 7550 +Wire Bus Line + 14650 4100 14650 5250 +Wire Bus Line + 4350 5650 4350 6350 +Wire Bus Line + 14650 5450 14650 7550 +Wire Bus Line + 7300 6350 7300 7050 +Wire Bus Line + 9700 6550 9700 7550 +Wire Bus Line + 7300 4950 7300 6150 +Wire Bus Line + 2400 4950 2400 6400 +$EndSCHEMATC diff --git a/card/apple2idiot_new/apple2idiot_new-rescue.dcm b/card/apple2idiot_new/apple2idiot_new-rescue.dcm new file mode 100644 index 0000000..5f3ed79 --- /dev/null +++ b/card/apple2idiot_new/apple2idiot_new-rescue.dcm @@ -0,0 +1,3 @@ +EESchema-DOCLIB Version 2.0 +# +#End Doc Library diff --git a/card/apple2idiot_new/apple2idiot_new-rescue.lib b/card/apple2idiot_new/apple2idiot_new-rescue.lib new file mode 100644 index 0000000..34b5ee1 --- /dev/null +++ b/card/apple2idiot_new/apple2idiot_new-rescue.lib @@ -0,0 +1,118 @@ +EESchema-LIBRARY Version 2.4 +#encoding utf-8 +# +# AppleIIBus-kicad-library +# +DEF AppleIIBus-kicad-library J 0 40 Y Y 1 F N +F0 "J" -550 1500 50 H V L CNN +F1 "AppleIIBus-kicad-library" 200 1500 50 H V L CNN +F2 "footprint:AppleIIBus" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +S -600 1450 600 -1450 0 1 0 f +X ~IOSEL 1 -700 -400 100 R 50 50 1 1 O +X A8 10 -700 500 100 R 50 50 1 1 O +X A9 11 -700 400 100 R 50 50 1 1 O +X A10 12 -700 300 100 R 50 50 1 1 O +X A11 13 -700 200 100 R 50 50 1 1 O +X A12 14 -700 100 100 R 50 50 1 1 O +X A13 15 -700 0 100 R 50 50 1 1 O +X A14 16 -700 -100 100 R 50 50 1 1 O +X A15 17 -700 -200 100 R 50 50 1 1 O +X R~W 18 -700 -700 100 R 50 50 1 1 O +X NC 19 -700 -1300 100 R 50 50 1 1 P +X A0 2 -700 1300 100 R 50 50 1 1 O +X ~IOSTROBE 20 -700 -500 100 R 50 50 1 1 O +X ~RDY 21 -700 -900 100 R 50 50 1 1 I +X ~DMA 22 700 -150 100 L 50 50 1 1 I +X INT_OUT 23 700 50 100 L 50 50 1 1 I +X DMA_OUT 24 700 -350 100 L 50 50 1 1 I +X +5V 25 -150 1550 100 D 50 50 1 1 w +X GND 26 0 -1550 100 U 50 50 1 1 w +X DMA_IN 27 700 -250 100 L 50 50 1 1 O +X INT_IN 28 700 150 100 L 50 50 1 1 O +X ~NMI 29 700 350 100 L 50 50 1 1 I +X A1 3 -700 1200 100 R 50 50 1 1 O +X ~IRQ 30 700 250 100 L 50 50 1 1 I +X ~RES 31 -700 -1100 100 R 50 50 1 1 O +X ~INH 32 -700 -1000 100 R 50 50 1 1 I +X -12V 33 150 1550 100 D 50 50 1 1 w +X -5V 34 -50 1550 100 D 50 50 1 1 w +X NC 35 700 -1250 100 L 50 50 1 1 P +X 7M 36 700 -850 100 L 50 50 1 1 O +X Q3 37 700 -750 100 L 50 50 1 1 O +X PHI1 38 700 -650 100 L 50 50 1 1 O +X USER1 39 700 -1050 100 L 50 50 1 1 P +X A2 4 -700 1100 100 R 50 50 1 1 O +X PHI0 40 700 -550 100 L 50 50 1 1 O +X ~DEVSEL 41 -700 -600 100 R 50 50 1 1 O +X D7 42 700 550 100 L 50 50 1 1 B +X D6 43 700 650 100 L 50 50 1 1 B +X D5 44 700 750 100 L 50 50 1 1 B +X D4 45 700 850 100 L 50 50 1 1 B +X D3 46 700 950 100 L 50 50 1 1 B +X D2 47 700 1050 100 L 50 50 1 1 B +X D1 48 700 1150 100 L 50 50 1 1 B +X D0 49 700 1250 100 L 50 50 1 1 B +X A3 5 -700 1000 100 R 50 50 1 1 O +X +12V 50 50 1550 100 D 50 50 1 1 w +X A4 6 -700 900 100 R 50 50 1 1 O +X A5 7 -700 800 100 R 50 50 1 1 O +X A6 8 -700 700 100 R 50 50 1 1 O +X A7 9 -700 600 100 R 50 50 1 1 O +ENDDRAW +ENDDEF +# +# ESP32-DEVKITC-32D-ESP32-DEV_KIT +# +DEF ESP32-DEVKITC-32D-ESP32-DEV_KIT U 0 40 Y Y 1 L N +F0 "U" -601 1026 50 H V L BNN +F1 "ESP32-DEVKITC-32D-ESP32-DEV_KIT" -601 -1101 50 H V L BNN +F2 "MODULE_ESP32-DEVKITC-32D" 0 0 50 H I L BNN +F3 "" 0 0 50 H I L BNN +F4 "4" 0 0 50 H I L BNN "PARTREV" +F5 "Espressif Systems" 0 0 50 H I L BNN "MANUFACTURER" +DRAW +S -600 -1000 600 1000 0 0 10 f +X 3V3 1 -800 900 200 R 40 40 0 0 W +X IO26 10 -800 0 200 R 40 40 0 0 B +X IO27 11 -800 -100 200 R 40 40 0 0 B +X IO14 12 -800 -200 200 R 40 40 0 0 B +X IO12 13 -800 -300 200 R 40 40 0 0 B +X GND1 14 -800 -400 200 R 40 40 0 0 W +X IO13 15 -800 -500 200 R 40 40 0 0 B +X SD2 16 -800 -600 200 R 40 40 0 0 B +X SD3 17 -800 -700 200 R 40 40 0 0 B +X CMD 18 -800 -800 200 R 40 40 0 0 B +X EXT_5V 19 -800 -900 200 R 40 40 0 0 W +X EN 2 -800 800 200 R 40 40 0 0 I +X GND3 20 800 900 200 L 40 40 0 0 W +X IO23 21 800 800 200 L 40 40 0 0 B +X IO22 22 800 700 200 L 40 40 0 0 B +X TXD0 23 800 600 200 L 40 40 0 0 O +X RXD0 24 800 500 200 L 40 40 0 0 I +X IO21 25 800 400 200 L 40 40 0 0 B +X GND2 26 800 300 200 L 40 40 0 0 W +X IO19 27 800 200 200 L 40 40 0 0 B +X IO18 28 800 100 200 L 40 40 0 0 B +X IO5 29 800 0 200 L 40 40 0 0 B +X SENSOR_VP 3 -800 700 200 R 40 40 0 0 I +X IO17 30 800 -100 200 L 40 40 0 0 B +X IO16 31 800 -200 200 L 40 40 0 0 B +X IO4 32 800 -300 200 L 40 40 0 0 B +X IO0 33 800 -400 200 L 40 40 0 0 B +X IO2 34 800 -500 200 L 40 40 0 0 B +X IO15 35 800 -600 200 L 40 40 0 0 B +X SD1 36 800 -700 200 L 40 40 0 0 B +X SD0 37 800 -800 200 L 40 40 0 0 B +X CLK 38 800 -900 200 L 40 40 0 0 I C +X SENSOR_VN 4 -800 600 200 R 40 40 0 0 I +X IO34 5 -800 500 200 R 40 40 0 0 B +X IO35 6 -800 400 200 R 40 40 0 0 B +X IO32 7 -800 300 200 R 40 40 0 0 B +X IO33 8 -800 200 200 R 40 40 0 0 B +X IO25 9 -800 100 200 R 40 40 0 0 B +ENDDRAW +ENDDEF +# +#End Library diff --git a/card/apple2idiot_new/sym-lib-table b/card/apple2idiot_new/sym-lib-table index a7a988d..2f08da4 100644 --- a/card/apple2idiot_new/sym-lib-table +++ b/card/apple2idiot_new/sym-lib-table @@ -1,3 +1,4 @@ (sym_lib_table (lib (name kicad-library)(type Legacy)(uri /home/equant/projects/apple_ii/other_peoples_stuff/rharke/kicad-library/kicad-library.lib)(options "")(descr "")) + (lib (name apple2idiot_new-rescue)(type Legacy)(uri ${KIPRJMOD}/apple2idiot_new-rescue.lib)(options "")(descr "")) ) diff --git a/notes.md b/notes.md index 2f6a571..c3b2902 100644 --- a/notes.md +++ b/notes.md @@ -1,3 +1,11 @@ +## Needed changes to board + +DONE: Add a GND and +5V breakout. +Fix DEVSEL address in silkscreen docs. +DONE: Unconnect addresses above A7. +DONE: Add diode to +5V. + + ## Ordered: * 5PCS IDT7132SA100P IDT7132SA DIP-48 HIGH-SPEED 2K x 8 DUAL-PORT STATIC RAM diff --git a/old/apple2idiot-breadboard_nondevkit.ino b/old/apple2idiot-breadboard_nondevkit.ino new file mode 100644 index 0000000..9a680af --- /dev/null +++ b/old/apple2idiot-breadboard_nondevkit.ino @@ -0,0 +1,458 @@ +/* +blah blah blah +*/ + +#define DEBUG true + +// Load Wi-Fi library +#include +#include +#include +#include +#include + +/**************/ +/* ESP32 Pins */ +/**************/ + +/* DATA BUS (numbers mean GPIO port) */ +#define D0R 12 +#define D1R 13 +#define D2R 14 +#define D3R 15 +#define D4R 18 +#define D5R 19 +#define D6R 21 +#define D7R 22 +byte data_pins[] = {D0R, D1R, D2R, D3R, D4R, D5R, D6R, D7R}; +#define DATA_BUS_SIZE 8 + +/* Address Bus */ +#define A0R 23 +#define A1R 25 +#define A2R 26 +#define A3R 27 +byte address_pins[] = {A0R, A1R, A2R, A3R}; +#define ADDRESS_BUS_SIZE 4 + +/* IDT7132S dual port ram chip enable */ +#define RW_PIN 5 +#define RW_WRITE LOW +#define RW_READ HIGH + +unsigned int data_byte = 0; + // fisrt bit is a flag for if the data is from Apple or from ESP32. + // / + // / last bit is a flag for "more data waiting to be sent". + // / / +#define COMMAND_FROM_APPLE 0 // 0_______ +#define COMMAND_FROM_ESP 128 // 1_______ +#define COMMAND_MORE_DATA_WAITING 1 // _0000001 +#define COMMAND_NO_DATA_WAITING 0 // _0000001 + +#define COMMAND_GENERIC_MESSAGE 2 // _000001_ +#define COMMAND_FETCH_WEATHER 4 // _000010_ +#define COMMAND_SEND_LONG_STRING 12 // _000110_ +#define COMMAND_FORMAT_RAM 126 // _111111_ + +#define ETX 3 // ASCII "End of Text" (ETX) character + +/************/ +/* Interupt */ +/************/ + +/* Variables shared between ISR and main code need to be volatile */ +volatile bool isr_handled = false; +volatile uint32_t raw_register_read; +volatile uint16_t raw_register1_read; + +/**********************/ +/* WiFi and Webserver */ +/**********************/ + +// Replace with your network credentials +const char* wifi_ssid = "GSO"; +const char* wifi_password = "xerxes27"; +AsyncWebServer web_server(80); +//WebServer web_server(80); + +/*******************/ +/* Weather Service */ +/*******************/ + +const String weather_service_api_key= "0ab97bbbea58592d7c9d64067a34d2d0"; +const String weather_url = "http://api.openweathermap.org/data/2.5/weather?"; + +/*********/ +/* Misc. */ +/*********/ + +const long readLoopInterval = 10000; // millis +unsigned long lastReadLoopTime = 0; +//byte ram[ADDRESS_BUS_SIZE]; +byte ram[16]; +volatile byte ram_busy=0; +//const unsigned int RAM_BUSY=666; +#define RAM_BUSY 666 + +/*################################################ +# ISR # +################################################*/ + +void IRAM_ATTR isrDEVSEL(void) { + raw_register_read = REG_READ(GPIO_IN_REG); + raw_register1_read = REG_READ(GPIO_IN1_REG); + isr_handled = true; +} + +/*################################################ +# Functions # +################################################*/ + +boolean set_address(int address) { + if (ram_busy) { + Serial.println("BUSY"); + return false; + } + ram_busy = true; + //Serial.print(" Setting address ("); + //Serial.print(address); + //Serial.println(")"); + //delay(20); + Serial.print(" A:"); + for (byte i=0; i 127) { + //if (requested_byte_to_write < 0) { + +boolean write_data(byte address, byte byte_to_write) { + Serial.print("WRITE: "); + Serial.print(byte_to_write); + Serial.print(" -> "); + Serial.println(address); + if (set_address(address)) { + //set_address(address); + Serial.print(" D:"); + for (byte i=0; i> i) & 0b00000001; + pinMode(data_pins[i], OUTPUT); + digitalWrite(data_pins[i], bit_to_write); + Serial.print(bit_to_write); + } + Serial.println(); + digitalWrite(RW_PIN, RW_WRITE); + delay(1); + digitalWrite(RW_PIN, RW_READ); + for (byte i=0; i 15 - 1) { // - 1 because of null character at end of string. + } else { + int c=0; + for (c=0; c < string_to_send.length(); c++) { + write_data(c, string_to_send[c]); + } + write_data(c+1, ETX); + write_data(15, COMMAND_FROM_ESP + command_message + COMMAND_NO_DATA_WAITING); + } +} + +void fetch_weather(char* city_name) { + HTTPClient http; + //http.begin(String(weather_url) + "?q=Tucson,us&APPID=" + String(weather_service_api_key)); + const String request_url = weather_url + "q=Tucson,us&APPID=" + weather_service_api_key; + Serial.println(request_url); + http.begin(request_url); + int httpCode = http.GET(); //Make the request + delay(10); + + if (httpCode > 0) { //Check for the returning code + String payload = http.getString(); + //Serial.println(httpCode); + Serial.println("++++++++++++++++++++++++"); + Serial.println(payload); + Serial.println("++++++++++++++++++++++++"); + StaticJsonDocument<200> filter; + filter["weather"][0]["main"] = true; + filter["weather"][0]["description"] = true; + filter["main"]["humidity"] = true; + filter["main"]["temp"] = true; + filter["wind"]["speed"] = true; + filter["wind"]["deg"] = true; + StaticJsonDocument<400> doc; + DeserializationError error = deserializeJson(doc, payload, DeserializationOption::Filter(filter)); + //DeserializationError error = deserializeJson(doc, payload); + if (error) { + Serial.print(F("deserializeJson() failed: ")); + Serial.println(error.f_str()); + } else { + //const char* main = doc["main"]; + Serial.println("----------------------"); + serializeJsonPretty(doc, Serial); + Serial.println("----------------------"); + serializeJsonPretty(doc["wind"], Serial); + Serial.println("----------------------"); + int temp = doc["main"]["humidity"]; + int humidity = doc["main"]["humidity"]; + float wind_speed = doc["wind"]["speed"]; + int wind_deg = doc["wind"]["speed"]; + String weather_description = doc["weather"][0]["description"]; + write_data(0, round(temp-273.15)); + write_data(1, round(humidity)); + write_data(2, round(wind_deg/10)); // divide by twn because 360 is too big for 8 bits + write_data(3, round(wind_speed)); + + } + + } + + else { + Serial.println("Error on HTTP request"); + } + + http.end(); //Free the resources +} + +void read_ram() { + for (int i=0; i < 16; i++) { + unsigned int foo = read_data(i); + ram[i] = foo; + } +} + +String html_template_processor(const String& var) { + Serial.println("html_template_processor()"); + String return_string = ""; + if (var == "RAM_TABLE") { + read_ram(); + for (int i=0; i < 16; i++) { + return_string += ""+String(i)+"" + String(ram[i]) + "\n"; + } + return return_string; + } + return var; +} + + +void www_weather(AsyncWebServerRequest *request) { + fetch_weather("Tucson"); + request->send(SPIFFS, "/ram.htm", String(), false, html_template_processor); +} +void www_root(AsyncWebServerRequest *request) { + request->send(SPIFFS, "/index.htm", String(), false, html_template_processor); +} +void www_ram(AsyncWebServerRequest *request) { + request->send(SPIFFS, "/ram.htm", String(), false, html_template_processor); +} +void www_write_byte(AsyncWebServerRequest *request) { + Serial.println("www_write_byte()"); + String address; + String data_byte; + if (request->hasParam("address")) { + address = request->getParam("address")->value(); + //Serial.println("Found address: "+address); + if (request->hasParam("data")) { + data_byte = request->getParam("data")->value(); + //Serial.println("Found data: "+data_byte); + write_data(address.toInt(), data_byte.toInt()); + } + } + request->send(SPIFFS, "/ram.htm", String(), false, html_template_processor); +} +void www_css(AsyncWebServerRequest *request) { + request->send(SPIFFS, "/a2i.css", "text/css"); +} + +void prefill_ram_with_pattern_data() { + write_data(15, 0); // notify Apple IIe we are done processing command byte + write_data(14, 123); // notify Apple IIe we are done processing command byte + write_data(13, 1); // notify Apple IIe we are done processing command byte + write_data(12, 123); // notify Apple IIe we are done processing command byte + write_data(11, 2); // notify Apple IIe we are done processing command byte + write_data(10, 123); // notify Apple IIe we are done processing command byte + write_data(9, 3); // notify Apple IIe we are done processing command byte + write_data(8, 123); // notify Apple IIe we are done processing command byte + write_data(7, 4); // notify Apple IIe we are done processing command byte + write_data(6, 123); // notify Apple IIe we are done processing command byte + write_data(5, 5); // notify Apple IIe we are done processing command byte + write_data(4, 123); // notify Apple IIe we are done processing command byte + write_data(3, 6); // notify Apple IIe we are done processing command byte + write_data(2, 123); // notify Apple IIe we are done processing command byte + write_data(1, 7); // notify Apple IIe we are done processing command byte + write_data(0, 123); // notify Apple IIe we are done processing command byte +} + +/*################################################ +# Setup # +################################################*/ + +void setup() { + + /* Configure ESP32 Pins */ + pinMode(A0R, OUTPUT); digitalWrite(A0R, LOW); + pinMode(A1R, OUTPUT); digitalWrite(A1R, LOW); + pinMode(A2R, OUTPUT); digitalWrite(A2R, LOW); + pinMode(A3R, OUTPUT); digitalWrite(A3R, LOW); + pinMode(D0R, INPUT); + pinMode(D1R, INPUT); + pinMode(D2R, INPUT); + pinMode(D3R, INPUT); + pinMode(D4R, INPUT); + pinMode(D5R, INPUT); + pinMode(D6R, INPUT); + pinMode(D7R, INPUT); + pinMode(RW_PIN, OUTPUT); digitalWrite(RW_PIN, RW_READ); + + delay(10); + //wifi_scan(); + + /* Connect to wifi */ + Serial.begin(115200); + Serial.println(""); + Serial.println("Starting wifi..."); + Serial.print(" connecting to: "); + Serial.println(wifi_ssid); + + WiFi.begin(wifi_ssid, wifi_password); + while (WiFi.status() != WL_CONNECTED) { + delay(900); + Serial.print("."); + } + Serial.println(""); + Serial.println("WiFi connected successfully"); + Serial.print("Got IP: "); + Serial.println(WiFi.localIP()); //Show ESP32 IP on serial + prefill_ram_with_pattern_data(); + store_ip_to_ram(0); + //store_ip_to_ram(4); + + /* Start webserver */ + if(!SPIFFS.begin()){ + Serial.println("An Error has occurred while mounting SPIFFS"); + } + web_server.on("/", HTTP_GET, www_root); + web_server.on("/a2i.css", HTTP_GET, www_css); + web_server.on("/ram", HTTP_GET, www_ram); + web_server.on("/write_byte", HTTP_GET, www_write_byte); + web_server.on("/weather", HTTP_GET, www_weather); + web_server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){ + request->send(200, "text/plain", "Free Heap: " + String(ESP.getFreeHeap()) + " bytes."); + }); + + //web_server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){ + //request->send(200, "text/plain", "Hello World"); + //}); + + //web_server.on("/", www_root); + web_server.begin(); + Serial.println("HTTP server started"); + delay(10); + + /* Display file system contents */ + Serial.println("-----------------------------------------"); + File root_filesystem = SPIFFS.open("/"); + File f = root_filesystem.openNextFile(); + while(f){ + Serial.print("FILE: "); + Serial.println(f.name()); + f = root_filesystem.openNextFile(); + } + Serial.println("-----------------------------------------"); + + //attachInterrupt(DEVSEL_PIN, isrDEVSEL, LOW); +} + +/*################################################ +# Main # +################################################*/ + +void loop() { + //if (isr_handled) { + //data_byte = raw_register_read >> 12 & 0b00000000000011111111; + //isr_handled = false; + //} + + if ((millis() - lastReadLoopTime) > readLoopInterval) { + //Serial.println("+++"); + unsigned int command_byte = read_data(15); + if (command_byte == RAM_BUSY) { + Serial.println("Command Read: RAM BUSY"); + } + else if (command_byte < COMMAND_FROM_ESP) { + // command came from apple (or webform). + Serial.print("Command Read: "); + Serial.println(command_byte); + //write_data(15, 1); // notify Apple IIe we are processing command byte + switch(command_byte) { + case COMMAND_FETCH_WEATHER: + Serial.println("Fetch Weather"); + fetch_weather("Tucson"); + break; + case COMMAND_SEND_LONG_STRING: + //send_string_to_apple("This is a long string", COMMAND_GENERIC_MESSAGE); + send_string_to_apple("ABCDE", COMMAND_GENERIC_MESSAGE); + case COMMAND_FORMAT_RAM: + Serial.println("Calling prefill_ram_with_pattern_data()"); + prefill_ram_with_pattern_data(); + write_data(15, 0); // notify Apple IIe we are done processing command byte + break; + } + /* + byte c = 0; + while (ram_busy && (c < 10)) { + delay(10); + c = c+1; + Serial.print("_"); + } + Serial.println("^^^^"); + write_data(15, 0); // notify Apple IIe we are done processing command byte + read_data(15); // notify Apple IIe we are done processing command byte + */ + } + lastReadLoopTime = millis(); + } +}