Arkadiusz Binder %!s(int64=4) %!d(string=hai) anos
pai
achega
6c951b20f7

+ 62 - 0
SE/stuff/p5_neuron_car/Simulated_potential_show_lcd.h

@@ -0,0 +1,62 @@
+
+
+
+
+
+
+void show_p0_neuron_title( ) {
+ String Label ;
+    for(int i=0; i<19;i++) {
+        if(NEURON_A[i].if_used == 1 ) {
+            lcd.setCursor(i,0);
+            Label = String(NEURON_A[i].Label) ;
+             lcd.print(Label);
+            // lcd.print(i);
+            // Serial.print(NEURON_A[i].Label);
+        }
+    }
+    //if_show_p0_neuron_title = 1 ;
+   
+}
+
+
+
+void Simulated_potential_show_lcd( ) {
+ 
+ if(Simulated_potential_show_lcd_t < millis()) {
+        Simulated_potential_show_lcd_t = millis() + Simulated_potential_show_lcd_latency ;
+        SPL();
+        lcd_menu();
+        //SPFT2(level,(( NEURON_A[0].Simulated_potential - NEURON_A[0].Reset_potential ) / ( NEURON_A[0].Firing_threshold -  NEURON_A[0].Reset_potential )) * 10 );
+        //SPFT2(level,(( NEURON_A[1].Simulated_potential - NEURON_A[1].Reset_potential ) / ( NEURON_A[1].Firing_threshold -  NEURON_A[1].Reset_potential )) * 10 );
+        //SPFT2(debug,NEURON_A[0].Capacitance);
+       // SPFT2(level,NEURON_A[1].Simulated_potential);
+       /*        
+            for(int i=0; i<19;i++) {
+                if(NEURON_A[i].if_used == 1  ) {
+                    lcd.setCursor(i,2);
+                    byte level = (( NEURON_A[i].Simulated_potential - NEURON_A[i].Reset_potential ) / ( NEURON_A[i].Firing_threshold -  NEURON_A[i].Reset_potential )) * 10 ;
+                    if(level >9) level = 0;
+                    Serial.print(i);SPFT2(level,level);
+                    lcd.print(level) ;
+                  
+                }
+            }
+       
+       
+        lcd.setCursor(0,3);   
+        lcd.print("L") ;lcd.print(int(neuron_Resting_Potenial_t_test_result)) ;  lcd.print(F("    "));
+        lcd.setCursor(5,3);
+         lcd.print(round(analogRead(AnalogSensorLL_PIN)/10 * AnalogSensorLL_calibrate_ratio)); lcd.print(F(" "));
+         lcd.print(round(analogRead(AnalogSensorLC_PIN)/10 * AnalogSensorLC_calibrate_ratio)); lcd.print(F(" "));
+         lcd.print(round(analogRead(AnalogSensorRC_PIN)/10 * AnalogSensorRC_calibrate_ratio)); lcd.print(F(" "));
+         lcd.print(round(analogRead(AnalogSensorRR_PIN)/10 * AnalogSensorRR_calibrate_ratio)); lcd.print(F(" "));
+         lcd.print(NEURON_A_INDEX_NEXT);  lcd.print(F(" ")); 
+         show_p0_neuron_title();
+
+         */
+         
+    }
+
+
+}

+ 2 - 0
SE/stuff/p5_neuron_car/config_Active_ControllerID.h

@@ -0,0 +1,2 @@
+//#define Active_ControllerID 0x38  //car
+#define Active_ControllerID 0x42  //car only pilot

+ 196 - 0
SE/stuff/p5_neuron_car/neuron-conf.h

@@ -0,0 +1,196 @@
+
+int PORT_to_NEURON_A_INDEX_NEXT = 0 ;
+int NEURON_A_INDEX_NEXT = 0 ; 
+int Current_synapse_A_INDEX_NEXT = 0 ;
+int Coordinate_Y_current_max = 30 ;
+int Coordinate_X_current_max = 10 ;
+
+int NEURON_TO_PORT_A_INDEX_NEXT = 0 ;
+
+
+int Coordinate_X_assign() {
+    
+    if(DISPLAY_PHYS_A[0].X > 300 and DISPLAY_PHYS_A[0].Y > 220) {
+            if(Coordinate_X_current_max + 30 < DISPLAY_PHYS_A[0].X ) {
+                Coordinate_X_current_max += 25 ;
+                return Coordinate_X_current_max;
+            } else {
+                Coordinate_X_current_max = 15;
+                Coordinate_Y_current_max += 50 ;
+                  return Coordinate_X_current_max;
+            }
+    } else {
+        
+            if(Coordinate_X_current_max + 15 < DISPLAY_PHYS_A[0].X ) {
+                Coordinate_X_current_max += 15 ;
+                return Coordinate_X_current_max;
+            } else {
+                Coordinate_X_current_max = 5;
+                Coordinate_Y_current_max += 15 ;
+                  return Coordinate_X_current_max;
+            }
+    }
+}
+
+
+int Coordinate_Y_assign() {
+    return Coordinate_Y_current_max ;
+}
+
+
+   
+     
+
+
+
+#include "config_Slave_Ports_LOCAL_neuron_config.h"
+
+
+bool NEURON_A_reset() {
+    NEURON_A_INDEX_NEXT = 0 ;
+    Coordinate_Y_current_max = 30 ; //0
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] =  'A'  ; NEURON_A[NEURON_A_INDEX_NEXT].Label[1] =  '\0'  ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ; 
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ; 
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ; 
+    //NEURON_A[NEURON_A_INDEX_NEXT].Capacitance = 2;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 1  ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT++ ;
+    //1 life
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'B' ; NEURON_A[NEURON_A_INDEX_NEXT].Label[1] =  '\0'  ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ;
+    //NEURON_A[NEURON_A_INDEX_NEXT].Capacitance = 2;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X =  DISPLAY_PHYS_A[0].X / 7 * 2 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT ++ ;
+    //2
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'C' ; NEURON_A[NEURON_A_INDEX_NEXT].Label[1] =  '\0'  ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ;
+    //NEURON_A[NEURON_A_INDEX_NEXT].Capacitance = 2;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 3 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT ++ ;
+    //3
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'D' ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ;
+    //NEURON_A[NEURON_A_INDEX_NEXT].Capacitance = 2;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 4 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT++ ;
+    //4
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'E' ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 5 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT++ ;
+    //5
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'F' ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Resistance = 50 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 6 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 10 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A_INDEX_NEXT ++ ;
+    //6
+    NEURON_A[NEURON_A_INDEX_NEXT].Label[0] = 'S' ;    NEURON_A[NEURON_A_INDEX_NEXT].Label[1] = '\0' ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Refactory_period__x3A__flag__x3A__until = millis() + 10000 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_used = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_modified = 1 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_X = DISPLAY_PHYS_A[0].X / 7 * 0 + 15 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Y = 30 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].Coordinate_Z = 0 ;
+    NEURON_A[NEURON_A_INDEX_NEXT].if_is_output = 1 ;
+
+    NEURON_A_INDEX_NEXT ++ ;
+    NEURON_A_reset_LOCAL();
+   
+    
+}
+
+bool Simulation_attract__x3A__calculate_A_reset() {
+}
+
+bool Current_synapse_A_reset() {
+    Current_synapse_A_INDEX_NEXT = 0 ;
+    
+     Current_synapse_A_reset_LOCAL();
+}
+
+bool PORT_to_NEURON_A_reset() {
+    PORT_to_NEURON_A_INDEX_NEXT = 0 ;
+    PORT_to_NEURON_A_reset_LOCAL() ;
+}
+
+bool set_conf() {
+    NEURON_TO_PORT_A_INDEX_NEXT = 0 ;
+    NEURON_A_reset() ;
+    Current_synapse_A_reset() ;
+    PORT_to_NEURON_A_reset();
+    //   #include "automation_driven.submodule.struct.write_neuron.scenario.h"
+
+    
+    
+}
+
+
+int AA_Delay_global_sequence_level = 0 ; //to maitain next sequence ordered
+
+bool set_conf_R = set_conf();
+
+
+
+//const int action_button_input_Maximum_current = 3 ;
+//const int action_button_input_Time_constant = 2 ;
+
+//const int neuron_Resting_Potenial_latency = 10 ; 
+const int neuron_Resting_Potenial_latency_test_print = 5000 ;
+
+//const int neuron_Refactory_period_ratio = 100 ; //to millis 
+//const int Current_synapse_A_Delay_ratio = 100 ; //to millis
+
+
+const int Simulated_potential_show_lcd_latency = 1000 ;
+
+//const int neuron_print_latency = 10 ;
+//const int neuron_print_if_has_input_millis_delay = 500 ; //extra keep active synapse for time to show
+const int neuron_Resting_Potenial__printed__level = 1 ; //below will not refresh
+//const long neuron_Attract_min = -65 ; //parametr glowny do attract
+
+//#define debug_Input_bypassed
+//#define debug_Attract_bypassed
+
+
+//#define NEURON_A_LIMIT 20 
+//#define Input_A_LIMIT 20 
+//#define Current_synapse_A_LIMIT 20 
+//#define Simulation_attract__x3A__calculate_A_LIMIT 10
+//#define Slave_Ports_Status_A_LIMIT 8 
+

+ 14 - 0
SE/stuff/p5_neuron_car/neuron_PCF8574.h

@@ -0,0 +1,14 @@
+
+
+
+void neuron_PCF8574_port_set() {
+    for(int i=0; i<Slave_Ports_Status_A_LIMIT; i++) {
+        if(Slave_Ports_Status_A[i].if_used == 1 and Slave_Ports_Status_A[i].if_modified == 1 ) {
+                
+                #include "_Slave_Ports_I2C_func_PCF8574.h"
+                
+                Slave_Ports_Status_A[i].if_modified = 0 ;
+        }
+    }
+
+}

+ 454 - 0
SE/stuff/p5_neuron_car/p5_neuron_car.ino

@@ -0,0 +1,454 @@
+#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
+   
+
+#include "__main_struct.h" //lite #include "___main/__main_struct.h"
+
+#include "progmem.h"
+
+#include "__main_struct_limits.h"
+#include "_PortTypes_struct.h"
+#include "_Port_Exp_state_ttl_struct.h"
+#include "_Port_Broadcast_state_struct.h"
+#include "_PortStates_struct.h"
+#include "_Port_I2C_driver_struct.h"
+#include "config_Active_ControllerID.h"
+#include "config_Slave_Ports_LOCAL_config.h" //lite
+
+#if defined(HAS_RF24)
+    #include "RF24_config.h"
+#endif
+     
+        
+#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 "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 = 320 ; 
+        DISPLAY_PHYS_A[0].Y = 240 ;
+    }
+    bool DISPLAY_PHYS_A_set_init = DISPLAY_PHYS_A_set();
+#endif
+
+
+
+
+#if defined(HAS_BH1750)
+    #include <Wire.h> //BH1750 IIC Mode 
+    #include <math.h> 
+    int BH1750address = 0x23; //setting i2c address
+    byte BH1750_buff[2];
+    bool if_BH1750_Init = 0 ;
+    void BH1750_Init(int address) 
+        {
+          Wire.beginTransmission(address);
+          Wire.write(0x10);//1lx reolution 120ms
+          Wire.endTransmission();
+        }
+        
+    int BH1750_Read(int address) //
+        {
+          int i=0;
+          Wire.beginTransmission(address);
+          Wire.requestFrom(address, 2);
+          while(Wire.available()) //
+          {
+            BH1750_buff[i] = Wire.read();  // receive one byte
+            i++;
+          }
+          Wire.endTransmission();  
+          return i;
+        }
+    
+#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 "config_Slave_Ports_LOCAL_init.h"
+#include "automation_driven.submodule.struct.write_neuron_override.h"
+
+
+
+
+#include "neuron-conf.h"
+
+
+#include "config_Slave_Ports_LOCAL_neuron_config.h"  
+
+
+
+#include "neuron_Input_func.h"
+#include "neuron_Stress_func.h"
+#include "neuron_Attract_func.h"
+#include "neuron_PORT_to_NEURON_func.h"
+#include "neuron_Resting_Potenial_func.h"
+
+
+
+#include "_TASK_TYPES_struct.h"
+
+bool neuron_print_ROTTARY_Coordinate_Y_SHIFT_flag = 0 ;
+
+
+#include "automation_driven.submodule.struct.write_neuron.lcd_menu.h"
+
+#include "Simulated_potential_show_lcd.h"
+
+#include "_time_struct.h"
+
+
+#if  defined(HAS_ADKeyboard)
+    #include "ADKeyboard.h"
+#endif
+
+
+ #if defined(HAS_TFT_HX8357) || defined(HAS_TFT_ILI9163C)
+    #include "neuron_print.h"
+ #endif
+// bool if_show_p0_neuron_title = 0 ;
+#include "TASK_TYPE_T_Get_Ports_Status_INPUT_A___.h"
+
+
+
+#include "_Slave_Ports_Status_func_add_lite.h"
+
+
+#if Active_ControllerID == 0x14 
+    #include "0x14/config_Slave_Ports_LOCAL_0x14_init.h"
+#elif Active_ControllerID == 0x35
+     #include "0x35/config_Slave_Ports_neuron_LOCAL_0x35_init.h"
+
+#elif Active_ControllerID == 0x38
+     #include "0x38/config_Slave_Ports_LOCAL_0x38_init.h"
+#elif Active_ControllerID == 0x42
+     #include "0x42/config_Slave_Ports_LOCAL_0x42_init.h"
+#else
+    #error not set  correct Active_ControllerID    
+#endif
+
+
+
+
+#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) {
+        
+            if(IOKey == 11) {//11 l 
+                lcd_menu__action_button_input__left() ;
+            } else if(IOKey == 12) { //12 up
+                lcd_menu__action_button_input__up() ;
+            } else if(IOKey == 13) {  //13 fire
+                lcd_menu__action_button_input__toggle() ;
+            } else if(IOKey == 14) { //14 dol
+                lcd_menu__action_button_input__down();
+            } else if(IOKey == 15) { //15 r
+                lcd_menu__action_button_input__right() ;
+            } else  {
+                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,neuron_Logic_A[0].action_button_input_Time_constant , neuron_Logic_A[0].action_button_input_Maximum_current, 0 );
+                Serial.print(F(" ")); Serial.print(NEURON_A[i].Simulated_potential);
+            }
+        } else  lcd.print(" ");
+    }
+    #elif defined(HAS_ADKeyboard)
+      if(IOKey == 1) {
+          lcd_menu__action_button_input__right() ;
+      } else if(IOKey == 2) {
+           lcd_menu__action_button_input__down();
+      } else if(IOKey == 3) {
+          lcd_menu__action_button_input__up() ;
+      } else if(IOKey == 4) {
+         lcd_menu__action_button_input__left() ;
+      } else if(IOKey == 5) {
+          lcd_menu__action_button_input__toggle() ;
+      } 
+        
+    #endif
+}
+
+
+#include "neuron_PCF8574.h"
+
+
+
+#if defined(HAS_HCSR04)
+    #include "HC-SR04.h" 
+#endif
+
+
+
+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();
+      DISPLAY_DEV.setRotation(1);
+    #elif defined(HAS_TFT_ILI9163C)
+     DISPLAY_DEV.begin();
+    #endif
+    
+    
+   
+     #if defined(HAS_TFT_HX8357) || defined(HAS_TFT_ILI9163C)
+     //   DISPLAY_DEV.setRotation(2);
+        DISPLAY_DEV.fillScreen(BLACK);//DISPLAY_DEV.clearScreen();
+        DISPLAY_DEV.setCursor(0,0);
+    
+      #endif
+
+        
+        #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);
+ */
+ 
+ 
+    TASK_TYPE_T_Get_Ports_Status_INPUT_A___SETUP();
+    
+     
+    
+    #if defined(PWM_Servo_PIN)
+        myservo.attach(PWM_Servo_PIN); 
+        myservo.write(90);
+    #endif   
+    #if defined(HAS_HCSR04)
+         pinMode(HCSR04_trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
+         pinMode(HCSR04_echoPin, INPUT); // Sets the echoPin as an INPUT
+    #endif
+    
+    
+    #if defined(HAS_ADKeyboard)
+     //   pinMode(ADKeyboard_PIN, INPUT_PULLUP) ; 
+    #endif
+    
+    #if defined(HAS_BH1750)
+          Wire.begin();
+    #endif
+    
+    #if defined(HAS_RF24)
+        #include "RF24_setup.h"
+    #endif
+    
+    
+  //  pinMode(11, OUTPUT);
+  //  pinMode(13, OUTPUT);
+  //  pinMode(3, OUTPUT);
+  //  pinMode(5, OUTPUT);
+  //  pinMode(A7, OUTPUT);
+  //  pinMode(13, OUTPUT);
+  //  digitalWrite(13,LOW);
+  // pinMode(A6, INPUT) ; 
+ }
+ 
+ 
+  
+ void loop() {
+    #include "p5_neuron_car_loop.h"
+    if(NEURON_TO_PORT_A_INDEX_NEXT > NEURON_TO_PORT_A_LIMIT) { SPFTFT2(limit,error,-321); SPFTFT2(value,error, NEURON_TO_PORT_A_INDEX_NEXT - NEURON_TO_PORT_A_LIMIT ) ;}
+    if(PORT_to_NEURON_A_INDEX_NEXT > PORT_to_NEURON_A_LIMIT) { SPFTFT2(limit,error,-322); SPFTFT2(value,error, PORT_to_NEURON_A_INDEX_NEXT - PORT_to_NEURON_A_LIMIT ) ; }
+     // digitalWrite(31,HIGH);
+     // digitalWrite(33,HIGH);
+      //SPFTFT2(level,debug,analogRead(A6));
+                                               
+
+                                            
+                                             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"));
+   #if defined(HAS_HCSR04)
+    HCSR04_input();
+   #endif
+  
+    #if defined(HAS_RF24) and HAS_RF24 == 1
+        #include "RF24_RX_loop.h"
+    #endif
+    neuron_PORT_to_NEURON();
+    
+    
+    neuron_Resting_Potenial_input();
+    neuron_Resting_Potenial();
+    
+    
+  //  Serial.print(F("C"));
+    Simulated_potential_show_lcd();
+    
+  //  Serial.print(F("P"));
+   #if defined(HAS_TFT_HX8357) || defined(HAS_TFT_ILI9163C)
+    neuron_print();
+   #endif
+    TASK_TYPE_T_Get_Ports_Status_INPUT_A___LOOP();
+    #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();
+         }
+    #elif  defined(HAS_ADKeyboard)
+        
+        
+        if(ADKeyboard_get_key_t > millis()) {
+        } else if(ADKeyboard_get_key()>0 and ADKeyboard_get_key_delay_t < millis()) {
+            ADKeyboard_get_key_delay_t = millis() + 100 ;
+        } else {
+                     IOKey=ADKeyboard_get_key();
+                        if(IOKey == 0) {
+                         IOKey_last = IOKey ;
+                         } else if(IOKey_last == IOKey and IOKey != 0) {
+                             
+                         }  else { 
+                             ADKeyboard_get_key_t = millis() + 300 ;
+                             IOKey_last = IOKey ;
+                             Serial.println(IOKey);
+                             Serial.print(F(" A "));
+                             SPFT2(input,analogRead(ADKeyboard_PIN));
+                             action_button_input();
+                 
+                 }
+              }
+    #endif
+ }

+ 77 - 0
SE/stuff/p5_neuron_car/p5_neuron_car_loop.h

@@ -0,0 +1,77 @@
+
+//0  LEWY TYL
+//1 LEWY TYL dir 
+//2  PRAWY TYL
+//3 PRAWY TYL dir
+//4 LEWY PRZOD
+//5 LEWY PRZOD dir
+//6 PRAWY PRZOD
+//7 PRAWY PRZOD dir
+
+//14  radio left
+//15  radio right
+//16  radio stop
+//17  radio SW
+//18  radio X LO
+//19  radio X HI
+//20  radio Y LO
+//21  radio Y HI
+//Slave_Ports_Status_A
+
+
+
+if(Slave_Ports_Status_A[16].Exp_state_level_A > 0 )  { //stop
+    SPFT2(stop,-24);
+    Slave_Ports_Status_A[16].Exp_state_level_A = 0 ;
+    analogWrite(Slave_Ports_Status_A[0].LocalPort , 0 ); //LEWY TYL
+        digitalWrite(Slave_Ports_Status_A[1].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[2].LocalPort , 0 ); //PRAWY TYL
+        digitalWrite(Slave_Ports_Status_A[3].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[4].LocalPort , 0 ); //LEWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[5].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[6].LocalPort , 0 ); //PRAWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[7].LocalPort, LOW) ;
+    delay(20);
+} else if(Slave_Ports_Status_A[14].Exp_state_level_A > 0) { //radio left
+     SPFT2(left,-30);
+     analogWrite(Slave_Ports_Status_A[4].LocalPort , 100 ); //LEWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[5].LocalPort, HIGH ) ;
+     analogWrite(Slave_Ports_Status_A[6].LocalPort , 100 ); //PRAWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[7].LocalPort, LOW ) ;
+     
+} else if(Slave_Ports_Status_A[15].Exp_state_level_A > 0) { //radio right
+     SPFT2(right,-33);
+      analogWrite(Slave_Ports_Status_A[4].LocalPort , 100 ); //LEWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[5].LocalPort, LOW ) ;
+     analogWrite(Slave_Ports_Status_A[6].LocalPort , 100 ); //PRAWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[7].LocalPort, HIGH ) ;
+    
+} else if(Slave_Ports_Status_A[20].Exp_state_level_A > 10) { //radio Y LO
+     SPFTFT2(forward,low,Slave_Ports_Status_A[20].Exp_state_level_A);
+    analogWrite(Slave_Ports_Status_A[0].LocalPort , Slave_Ports_Status_A[20].Exp_state_level_A ); //LEWY TYL
+    analogWrite(Slave_Ports_Status_A[2].LocalPort , Slave_Ports_Status_A[20].Exp_state_level_A ); //PRAWY TYL
+    analogWrite(Slave_Ports_Status_A[4].LocalPort , Slave_Ports_Status_A[20].Exp_state_level_A -  Slave_Ports_Status_A[18].Exp_state_level_A ); //LEWY PRZOD - X LO
+    analogWrite(Slave_Ports_Status_A[6].LocalPort , Slave_Ports_Status_A[20].Exp_state_level_A -  Slave_Ports_Status_A[19].Exp_state_level_A  ); //PRAWY PRZOD - X HI
+} else if(Slave_Ports_Status_A[21].Exp_state_level_A > 10) { //radio Y HI
+     SPFTFT2(forward,high,Slave_Ports_Status_A[21].Exp_state_level_A);
+    analogWrite(Slave_Ports_Status_A[0].LocalPort , 150 - Slave_Ports_Status_A[21].Exp_state_level_A ); //LEWY TYL
+        digitalWrite(Slave_Ports_Status_A[1].LocalPort, HIGH) ;
+    analogWrite(Slave_Ports_Status_A[2].LocalPort , 150 - Slave_Ports_Status_A[21].Exp_state_level_A ); //PRAWY TYL
+        digitalWrite(Slave_Ports_Status_A[3].LocalPort, HIGH) ;
+    analogWrite(Slave_Ports_Status_A[4].LocalPort , 150 - Slave_Ports_Status_A[21].Exp_state_level_A ); //LEWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[5].LocalPort, HIGH) ;
+    analogWrite(Slave_Ports_Status_A[6].LocalPort , 150 - Slave_Ports_Status_A[21].Exp_state_level_A ); //PRAWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[7].LocalPort, HIGH) ;
+
+
+}  else { //stop else
+
+    analogWrite(Slave_Ports_Status_A[0].LocalPort , 0 ); //LEWY TYL
+        digitalWrite(Slave_Ports_Status_A[1].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[2].LocalPort , 0 ); //PRAWY TYL
+        digitalWrite(Slave_Ports_Status_A[3].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[4].LocalPort , 0 ); //LEWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[5].LocalPort, LOW) ;
+    analogWrite(Slave_Ports_Status_A[6].LocalPort , 0 ); //PRAWY PRZOD
+        digitalWrite(Slave_Ports_Status_A[7].LocalPort, LOW) ;
+}

+ 40 - 3
se.oxygen.xpr

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project version="22.0">
+<project>
     <meta>
         <filters directoryPatterns="" filePatterns="se.oxygen.xpr" positiveFilePatterns="" showHiddenFiles="false"/>
         <options>
-            <serialized version="22.0" xml:space="preserve">
+            <serialized xml:space="preserve">
                 <serializableOrderedMap>
                     <entry>
                         <String>enable.project.master.files.support</String>
@@ -3939,6 +3939,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonBAdvancedOptions>
                                         </entry>
                                     </serializableOrderedMap>
@@ -4245,6 +4251,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonBAdvancedOptions>
                                         </entry>
                                     </serializableOrderedMap>
@@ -4771,6 +4783,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonHEAdvancedOptions>
                                         </entry>
                                         <entry>
@@ -4827,6 +4845,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonBAdvancedOptions>
                                         </entry>
                                     </serializableOrderedMap>
@@ -5031,6 +5055,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonHEAdvancedOptions>
                                         </entry>
                                         <entry>
@@ -5087,6 +5117,12 @@
                                                 <field name="initializer">
                                                     <String></String>
                                                 </field>
+                                                <field name="profilingOutputFile">
+                                                    <null/>
+                                                </field>
+                                                <field name="isProfilingEnabled">
+                                                    <Boolean>false</Boolean>
+                                                </field>
                                             </xsltSaxonBAdvancedOptions>
                                         </entry>
                                     </serializableOrderedMap>
@@ -5310,7 +5346,7 @@
             </serialized>
         </options>
     </meta>
-    <projectTree name="SE.oxygen.xpr">
+    <projectTree name="se.oxygen.xpr">
         <folder masterFiles="true" name="Master Files">
             <file name="SE/schema/default_db_xml_cache.public/_procesy_gen.xsl"/>
             <file name="SE/schema/default_db_xml_cache.public/_stanowiska_nazwy_gen_ant.xsl"/>
@@ -5679,6 +5715,7 @@
             <folder path="SE/schema/ant-object/"/>
             <folder path="SE/schema/WPS_Functions/dita-ot/dita-ot-3.3.3/plugins/org.dita.pdf2/"/>
             <folder path="SE/schema/WPS_Functions/SvgCharts4Xsl/"/>
+            <folder path="SE/stuff/"/>
         </folder>
         <folder name="xmschema">
             <folder path="../../procesy5-dita-templates-druki/xmlschema_procesy5/src-xmlschema/public_html/"/>