| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- #include "Arduino.h"
- #include <Servo.h>
- Servo myservo;
-
- #define Port7 7 //for TFT_ILI9163C_CSpin 7
- #define Port8 8 //for TFT_ILI9163C_DCpin 8
- #define Port9 9 //for TFT_ILI9163C__RSTpin 9
- #define TFT_ILI9163C_CSpin Port7 // 7 // __CSpin // 53 // 10 // chip select
-
-
- #if ! defined(TFT_ILI9163C_DCpin)
- #define TFT_ILI9163C_DCpin Port8 //8 // A0 data/command pin. sometimes called DC, RS, ...
- #endif
- #if ! defined(TFT_ILI9163C__RSTpin)
- #define TFT_ILI9163C__RSTpin Port9 //9 //reset pin. you must connect. (or pullup)
- #endif
- #include "__main_struct.h" //lite #include "___main/__main_struct.h"
- #include "progmem.h"
- #include "__main_struct_limits.h"
- #include "config_Active_ControllerID.h"
- #include "config_Slave_Ports_LOCAL_config.h" //lite
- #include "automation_driven.submodule.struct.write_neuron.h"
- #if defined(HAS_LCD1602_I2C)
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,LCD1602_DISPLAY_PHYSICAL_X_CHARS_A,LCD1602_DISPLAY_PHYSICAL_Y_CHARS_A);
- #endif
-
- #if defined(HAS_TFT_ILI9163C)
- #include "_TFT_ILI9163C_config.h"
- // #include "_TFT_ILI9163C_struct.h"
- bool DISPLAY_PHYS_A_set() {
- DISPLAY_PHYS_A[0].X = 128 ;
- DISPLAY_PHYS_A[0].Y = 128 ;
- }
- bool DISPLAY_PHYS_A_set_init = DISPLAY_PHYS_A_set();
- TFT_ILI9163C DISPLAY_DEV = TFT_ILI9163C(TFT_ILI9163C_CSpin, TFT_ILI9163C_DCpin, TFT_ILI9163C__RSTpin); //#include "_TFT_ILI9163C_func.h"
- #elif defined(HAS_TFT_HX8357)
- #include <TFT_HX8357.h>
- // #error test
- TFT_HX8357 DISPLAY_DEV = TFT_HX8357(); // Invoke custom library
- bool DISPLAY_PHYS_A_set() {
- DISPLAY_PHYS_A[0].X = 240 ;
- DISPLAY_PHYS_A[0].Y = 320 ;
- }
- bool DISPLAY_PHYS_A_set_init = DISPLAY_PHYS_A_set();
- #endif
- #if defined(HAS_W5IOKeypad)
- #include <W5IOKeypad.h>
- #endif
- #if defined(HAS__PCINT_setup)
- #include "_PCINT_struct.h" //pins MYPIN1 MYPIN2 MYPIN3
- #endif
- #if defined(HAS_ROTTARY_SW)
- #include "_ROTTARY_SW_config.h" //_ROTTARY_SW/
- #endif
- #if defined(HAS_ROTTARY_SW)
- #include "_ROTTARY_SW_struct.h" //lite _ROTTARY_SW/
- #else
- int encoderPos = 0 ;
- int oldEncPos = 0 ;
- int triggerCount = 0 ;
- int triggerCountOld = 0 ;
- #endif
- #if defined(HAS_ROTTARY_SW)
- #include "_ROTTARY_SW_func.h" //lite _ROTTARY_SW/
- #endif
- #if defined(HAS__PCINT_setup)
- #include "_PCINT_init.h"
- #endif
- #include "neuron-conf.h"
- #include "neuron_Input_func.h"
- #include "neuron_Attract_func.h"
- #include "neuron_Resting_Potenial_func.h"
- #include "Simulated_potential_show_lcd.h"
- #include "neuron_print.h"
- // bool if_show_p0_neuron_title = 0 ;
- #if defined(HAS_W5IOKeypad)
- W5IOKeypad Keypad( W5IOKeypad_PIN_GND, W5IOKeypad_PIN_IO1, W5IOKeypad_PIN_IO2, W5IOKeypad_PIN_IO3, W5IOKeypad_PIN_IO4, W5IOKeypad_PIN_IO5 );
- int IOKey = 0;
- int IOKey_last = 0;
- #endif
- void action_button_input( ) {
- #if defined(HAS_W5IOKeypad)
- for(int i=0; i<20;i++) {
- lcd.setCursor(i,1);
- if(IOKey == i+1) {
- lcd.print("+");
- //NEURON_A[i].Simulated_potential = NEURON_A[i].Simulated_potential + ( action_button_input_Maximum_current * action_button_input_Time_constant ) / NEURON_A[i].Capacitance ;
- neuron_Input(i,action_button_input_Time_constant,action_button_input_Maximum_current, 0 );
- Serial.print(F(" ")); Serial.print(NEURON_A[i].Simulated_potential);
- } else lcd.print(" ");
- }
- #endif
- }
- #include "neuron_PCF8574.h"
- void setup() { //REMEMBER NOT INITIALIZE ANY VARIABLES OR ARRAYS
- Serial.begin(115200);
- lcd.init(); // Print a message to the LCD.
- lcd.backlight();
- lcd.setCursor(0,0);
- //lcd.print("debug neuron ");
- #if defined(HAS_TFT_HX8357)
- DISPLAY_DEV.init();
- #else
- DISPLAY_DEV.begin();
- #endif
- // DISPLAY_DEV.setRotation(2);
- DISPLAY_DEV.fillScreen(BLACK);//DISPLAY_DEV.clearScreen();
- DISPLAY_DEV.setCursor(0,0);
-
-
-
- #if defined(HAS__PCINT_setup)
- #include "_PCINT_setup.h" //empty
- #endif
-
-
- #if defined(HAS_ROTTARY_SW)
- #include "_ROTTARY_SW_setup.h" //Attach interrupts //lite _ROTTARY_SW/
- #endif
-
- show_p0_neuron_title();
-
- pinMode(AnalogSensorLL_PIN, INPUT_PULLUP);
- pinMode(AnalogSensorLC_PIN, INPUT_PULLUP);
- pinMode(AnalogSensorRC_PIN, INPUT_PULLUP);
- pinMode(AnalogSensorRR_PIN, INPUT_PULLUP);
-
- myservo.attach(PWM_Servo_PIN);
- myservo.write(90);
- }
-
-
-
-
- void loop() {
- // Serial.println(F("L"));
-
- if(triggerCount != triggerCountOld) {
-
- SPFTFT2(rottary,trigger,triggerCount);
-
- if(triggerCountOld_t < millis()) {
- triggerCountOld_t = millis() + 500 ;
- triggerCountOld = triggerCount ;
- } else {
- SPFTFTFTFT(rottary,trigger,time,bypassed);
- triggerCountOld = triggerCount ;
- }
-
- }
-
-
-
-
-
-
-
-
-
-
-
- // if(if_show_p0_neuron_title == 0) show_p0_neuron_title() ;
- // Serial.print(F("R"));
- neuron_Resting_Potenial();
- // Serial.print(F("C"));
- Simulated_potential_show_lcd();
- // Serial.print(F("P"));
- neuron_print();
-
- #if defined(HAS_W5IOKeypad)
- // Serial.print(F("K"));
- IOKey=Keypad.ReadButtons();
- if(IOKey == 0) {
- IOKey_last = IOKey ;
- } else if(IOKey_last == IOKey and IOKey != 0) {
- // Serial.print(F("K"));
- } else {
- IOKey_last = IOKey ;
- Serial.println(IOKey);
- Serial.print(F("A"));
- action_button_input();
- }
- #endif
- // delay(100);
- }
|