Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*History Version 1.0 Variablen aus Ebene 0 (SBH) angelegt
- Funktioniert!
- 1.1 Daten direkt in CAN Data 0 schreiben Also ohne Variable Data00 für Nachricht 1 & 2
- 1.2 Nachricht 3 von Modul 4 hinzugefügt - Funktioniert
- 1.3 Nachricht 4 von Modul 5 hinzugefügt - funktioniert
- 1.4 Nachricht 5 von Modul 6 hinzugefügt - funktioniert
- 1.5 Nachricht 6 von Modul 8 hinzugefügt - funktioniert
- 1.6 LCD ANzeige hinzugefügt und State maschine für Display LCD Anzeige bis Modul3 programiert
- 1.7 Modul 4,5,6,7,8,9,10 und 11 hinzugefügt.--- Funktioniert
- 1.8 Code verschönert, leerzeichen usw gelöscht
- 2.0 Sendesequenz zu Modul 2 implementiert
- */
- // -------------------------------------- Umbenenen der STM Pins
- // Bliotheken
- //------------------------------------------------------------------------------------------------------------Testweise auskommentiert #include <assert.h>
- #include "stm32f103.h" // Bei selbst erstellten Bibliotheken der name immer in Anführungszeichen!! Nicht in größer kleiner als Zeichen!
- #include <LiquidCrystal.h>
- // EIngänge
- const int rs = PA0, en = PA1, d4 = PA2, d5 = PA3, d6 = PA4, d7 = PA5;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- const int NextAnzeige = PA9;
- const int TestCAN1 = PB15;
- const int TestCAN2 = PA8;
- uint8_t NextAnzeigeState = 0;
- uint8_t TestCAN1State = 0;
- uint8_t TestCAN2State = 0;
- // Ausgänge
- uint8_t counter = 0; // Zahler für nachricht wurde x mal versand
- uint8_t frameLength = 0; // framelegth ist die länge der nachricht hier kann man auch im Sendeteil eine Zahl angeben
- unsigned long previousMillis = 0; // stores last time output was updated
- const long interval = 100; // transmission interval (milliseconds) Intervall in dem gesendet wird
- CAN_msg_t CAN_TX_msg; // Initialisierung Senden
- CAN_msg_t CAN_RX_msg; // Initialisierung EMPFANGEN
- //-------------------------------------------------------Variablen
- // Modul 2 SBH Süd Einfahrt
- uint8_t LSEinfahrtSBHSudState = 0;
- uint8_t LSVmaxSBHSudState = 0;
- uint8_t LSEinfahrtWendelSudState = 0;
- uint8_t WeicheEinfahrtSBHSudGeradeausState = 0;
- uint8_t WeicheEinfahrtSBHSudAbbiegenState = 0;
- // Modul 3 SBH Süd rechts
- uint8_t LSEinfahrtSBHSudGleis1State = 0;
- uint8_t LSEinfahrtSBHSudGleis2State = 0;
- uint8_t LSEinfahrtSBHSudGleis3State = 0;
- uint8_t LSEinfahrtSBHSudGleis4State = 0;
- uint8_t LSEinfahrtSBHSudGleis5State = 0;
- uint8_t WeicheSBHSudGleis1geradeausState = 0;
- uint8_t WeicheSBHSudGleis1abbiegenState = 0;
- uint8_t WeicheSBHSudGleis2geradeausState = 0;
- uint8_t WeicheSBHSudGleis2abbiegenState = 0;
- uint8_t WeicheSBHSudGleis3geradeausState = 0;
- uint8_t WeicheSBHSudGleis3abbiegenState = 0;
- uint8_t WeicheSBHSudGleis4geradeausState = 0;
- uint8_t WeicheSBHSudGleis4abbiegenState = 0;
- // Modul4 SBH süd links
- uint8_t LSEndposSBHSudGleis1State = 0;
- uint8_t LSEndposSBHSudGleis2State = 0;
- uint8_t LSEndposSBHSudGleis3State = 0;
- uint8_t LSEndposSBHSudGleis4State = 0;
- uint8_t LSEndposSBHSudGleis5State = 0;
- // Modul5 SBH Süd Kehrschleife
- uint8_t LSEinfahrtKehrschleifeSBHSudState = 0;
- uint8_t WeicheKehrschleifeSBHSudGeradeausState = 0;
- uint8_t WeicheKehrschleifeSBHSudAbbiegenState = 0;
- // Modul6 Kreuzung
- uint8_t LSEinfahrtVonSBHWest1State = 0;
- uint8_t LSEinfahrtVonSBHWest2State = 0;
- uint8_t LSEinfahrtVonSBHSudState = 0;
- uint8_t LSEinfahrtVonWendelWestState = 0;
- uint8_t FahrstromSBHWestWendelSudState = 0;
- uint8_t FahrstromSBHWestWendelWestState = 0;
- uint8_t FahrstromSBHSudWendelSudState = 0;
- uint8_t FahrstromSBHSudWendelWestState = 0;
- uint8_t FahrstromKreuzungAllgemeinState = 0;
- uint8_t WeicheKehrschleifeSBHWestGeradeausState = 0;
- uint8_t WeicheKehrschleifeSBHWestAbbiegenState = 0;
- // Modul 8 SBH West rechts
- uint8_t LSEndposSBHWestGleis1State = 0;
- uint8_t LSEndposSBHWestGleis2State = 0;
- uint8_t LSEndposSBHWestGleis3State = 0;
- uint8_t LSEndposSBHWestGleis4State = 0;
- uint8_t LSEndposSBHWestGleis5State = 0;
- uint8_t FahrstromSBHWestGleis1State = 0;
- uint8_t FahrstromSBHWestGleis2State = 0;
- uint8_t FahrstromSBHWestGleis3State = 0;
- uint8_t FahrstromSBHWestGleis4State = 0;
- uint8_t FahrstromSBHWestGleis5State = 0;
- uint8_t FahrstromSBHSudAllgemeinState = 0;
- // Modul 9 SBH West Links
- uint8_t LSEinfahrtSBHWestGleis1State = 0;
- uint8_t LSEinfahrtSBHWestGleis2State = 0;
- uint8_t LSEinfahrtSBHWestGleis3State = 0;
- uint8_t LSEinfahrtSBHWestGleis4State = 0;
- uint8_t LSEinfahrtSBHWestGleis5State = 0;
- uint8_t WeicheSBHWestGleis1geradeausState = 0;
- uint8_t WeicheSBHWestGleis1abbiegenState = 0;
- uint8_t WeicheSBHWestGleis2geradeausState = 0;
- uint8_t WeicheSBHWestGleis2abbiegenState = 0;
- uint8_t WeicheSBHWestGleis3geradeausState = 0;
- uint8_t WeicheSBHWestGleis3abbiegenState = 0;
- uint8_t WeicheSBHWestGleis4geradeausState = 0;
- uint8_t WeicheSBHWestGleis4abbiegenState = 0;
- // Modul 10 Einfahrt SBH West
- uint8_t LSEinfahrtSBHWestState = 0;
- uint8_t LSVmaxSBHWestState = 0;
- uint8_t LSEinfahrtWendelWestState = 0;
- uint8_t WeicheEinfartSBHWestGeradeausState = 0;
- uint8_t WeicheEinfahrtSBHWestAbbiegenState = 0;
- // --------------- State Maschine
- enum LCDANZEIGE
- {
- MODUL1 , MODUL2 , MODUL3 , MODUL4 , MODUL5 , MODUL6 , MODUL7 , MODUL8 , MODUL9 , MODUL10 , MODUL11 , ZENTRALE
- };
- LCDANZEIGE akt_state_LCDANZEIGE = MODUL1;
- LCDANZEIGE next_state_LCDANZEIGE = MODUL1;
- void setup()
- {
- // -------------------------------------- pinMode
- pinMode(NextAnzeige, INPUT);
- pinMode(TestCAN1, INPUT);
- pinMode(TestCAN2, INPUT);
- pinMode(LED_BUILTIN, OUTPUT); //LED auf Arduino Blinken um programierung zu bestätigen
- delay(1500);
- digitalWrite(PC13, HIGH);
- delay(500);
- digitalWrite(PC13, LOW);
- delay(500);
- digitalWrite(PC13, HIGH);
- delay(500);
- digitalWrite(PC13, LOW);
- delay(500);
- digitalWrite(PC13, HIGH);
- // CAN aktivieren
- {
- Serial.begin(115200);
- bool ret = CANInit(CAN_500KBPS, 0); // CAN_RX mapped to PA11, CAN_TX mapped to PA12
- if (!ret) while (true);
- }
- // LCD initialisieren
- {
- lcd.begin(20, 4);
- lcd.print("Tach Kay!");
- delay(1000);
- lcd.clear();
- delay(1000);
- }
- }
- void loop()
- {
- // put your main code here, to run repeatedly:
- // ---------------------------- Begin CAN
- {
- // ---------------------------- Begin CAN Empfangen
- {
- // ---------------------------- CAN Nachricht 0x000001 empfangen LED 1 & 2 Grün und Rot
- if (CANMsgAvail())
- {
- CANReceive(&CAN_RX_msg); // Prüfen ob neue Nacvhricht empfangen werden kann (liegt eine neue Nachricht zum abholen bereit?)
- if (CAN_RX_msg.type == DATA_FRAME)
- {
- if (CAN_RX_msg.id == 0x100001) // Empfang der nachricht 0x100001 von Modul 2
- {
- LSEinfahrtSBHSudState = bitRead (CAN_RX_msg.data[0], 0);
- LSVmaxSBHSudState = bitRead (CAN_RX_msg.data[0], 1);
- LSEinfahrtWendelSudState = bitRead (CAN_RX_msg.data[0], 2);
- }
- if (CAN_RX_msg.id == 0x100002) // nachrichten ID 0x100002 von Modul 3
- {
- LSEinfahrtSBHSudGleis1State = bitRead(CAN_RX_msg.data[0], 0);
- LSEinfahrtSBHSudGleis2State = bitRead(CAN_RX_msg.data[0], 1);
- LSEinfahrtSBHSudGleis3State = bitRead(CAN_RX_msg.data[0], 2);
- LSEinfahrtSBHSudGleis4State = bitRead(CAN_RX_msg.data[0], 3);
- LSEinfahrtSBHSudGleis5State = bitRead(CAN_RX_msg.data[0], 4);
- }
- if (CAN_RX_msg.id == 0x100003) // nachrichten ID 0x100003 von Modul 4
- {
- LSEndposSBHSudGleis1State = bitRead(CAN_RX_msg.data[0], 0);
- LSEndposSBHSudGleis2State = bitRead(CAN_RX_msg.data[0], 1);
- LSEndposSBHSudGleis3State = bitRead(CAN_RX_msg.data[0], 2);
- LSEndposSBHSudGleis4State = bitRead(CAN_RX_msg.data[0], 3);
- LSEndposSBHSudGleis5State = bitRead(CAN_RX_msg.data[0], 4);
- }
- if (CAN_RX_msg.id == 0x100004) // nachrichten ID 0x100004 von Modul 5
- {
- LSEinfahrtKehrschleifeSBHSudState = bitRead(CAN_RX_msg.data[0], 0);
- }
- if (CAN_RX_msg.id == 0x100005) // nachrichten ID 0x100005 von Modul 6
- {
- LSEinfahrtVonSBHWest1State = bitRead(CAN_RX_msg.data[0], 0);
- LSEinfahrtVonSBHWest2State = bitRead(CAN_RX_msg.data[0], 1);
- LSEinfahrtVonSBHSudState = bitRead(CAN_RX_msg.data[0], 2);
- LSEinfahrtVonWendelWestState = bitRead(CAN_RX_msg.data[0], 3);
- }
- if (CAN_RX_msg.id == 0x100006) // nachrichten ID 0x100006 von Modul 8
- {
- LSEndposSBHWestGleis1State = bitRead(CAN_RX_msg.data[0], 0);
- LSEndposSBHWestGleis2State = bitRead(CAN_RX_msg.data[0], 1);
- LSEndposSBHWestGleis3State = bitRead(CAN_RX_msg.data[0], 2);
- LSEndposSBHWestGleis4State = bitRead(CAN_RX_msg.data[0], 3);
- LSEndposSBHWestGleis5State = bitRead(CAN_RX_msg.data[0], 4);
- }
- if (CAN_RX_msg.id == 0x100007) // nachrichten ID 0x100007 von Modul 9
- {
- LSEinfahrtSBHWestGleis1State = bitRead(CAN_RX_msg.data[0], 0);
- LSEinfahrtSBHWestGleis2State = bitRead(CAN_RX_msg.data[0], 1);
- LSEinfahrtSBHWestGleis3State = bitRead(CAN_RX_msg.data[0], 2);
- LSEinfahrtSBHWestGleis4State = bitRead(CAN_RX_msg.data[0], 3);
- LSEinfahrtSBHWestGleis5State = bitRead(CAN_RX_msg.data[0], 4);
- }
- if (CAN_RX_msg.id == 0x100008) // Empfang der nachricht 0x100008 von Modul 10
- {
- LSEinfahrtSBHWestState = bitRead (CAN_RX_msg.data[0], 0);
- LSVmaxSBHWestState = bitRead (CAN_RX_msg.data[0], 1);
- LSEinfahrtWendelWestState = bitRead (CAN_RX_msg.data[0], 2);
- }
- }
- }
- }
- // Ende CAN Empfangen
- // begin CAN senden
- {
- {
- // ---------------------------- Begin CAN Nachricht 0x10009 senden
- // eigentliche Daten werden eingefüllt
- // mit bitwrite lassen sich einzelne bits innerhalb eines Bytes beschreiben. Hier Zustand TasterState in Erstes (ganz rechtes) Bit von Data0 schreiben
- bitWrite (CAN_TX_msg.data[0], 0, WeicheEinfahrtSBHSudGeradeausState); // Data 00 Steuerung der Ausgaenge Modul2 Einfahrt SBH Sued
- bitWrite (CAN_TX_msg.data[0], 1, WeicheEinfahrtSBHSudAbbiegenState);
- bitWrite (CAN_TX_msg.data[1], 0, WeicheSBHSudGleis1geradeausState); // Data 01 Steuerung der Ausgaenge Modul3 SBH Sued Rechts
- bitWrite (CAN_TX_msg.data[1], 1, WeicheSBHSudGleis1abbiegenState);
- bitWrite (CAN_TX_msg.data[1], 2, WeicheSBHSudGleis1geradeausState);
- bitWrite (CAN_TX_msg.data[1], 3, WeicheSBHSudGleis1abbiegenState);
- bitWrite (CAN_TX_msg.data[1], 4, WeicheSBHSudGleis1geradeausState);
- bitWrite (CAN_TX_msg.data[1], 5, WeicheSBHSudGleis1abbiegenState);
- bitWrite (CAN_TX_msg.data[1], 6, WeicheSBHSudGleis1geradeausState);
- bitWrite (CAN_TX_msg.data[1], 7, WeicheSBHSudGleis1abbiegenState); // Data 02 Steuerung der Ausgänge Modul3 SBH Sued Rechts
- CAN_TX_msg.len = 2; // Länge der Nachricht
- unsigned long currentMillis = millis(); // Senden alle x millisekunden
- if (currentMillis - previousMillis >= interval)
- {
- previousMillis = currentMillis;
- if ( ( counter % 2) == 0)
- { // Rest der Nachricht wird befüllt
- CAN_TX_msg.type = DATA_FRAME;
- if (CAN_TX_msg.len == 0) CAN_TX_msg.type = REMOTE_FRAME;
- CAN_TX_msg.format = EXTENDED_FORMAT;
- CAN_TX_msg.id = 0x100009; // nachrichten ID
- }
- CANSend(&CAN_TX_msg); // Übergabe der Nachricht an die Hardware
- }
- //// ---------------------------- Ende CAN Nachricht 0x10009 senden an Modul 2
- }
- }
- }
- // ---------------------------------------------------- Ende CAN
- // ------------------------------------- Ansteuerung LCD 20x4 Beginn
- {
- // -------------------------------------- State Maschine für LCD Anzeige
- if (next_state_LCDANZEIGE != akt_state_LCDANZEIGE) // Hat sich der State geändert ?
- {
- switch (next_state_LCDANZEIGE) // State Mashine für Wechselzwischen den Sates
- {
- case MODUL1:
- {
- lcd.clear(); // immer nur das LCd einmal löschen
- }
- case MODUL2:
- {
- lcd.clear();
- }
- case MODUL3:
- {
- lcd.clear();
- }
- case MODUL4:
- {
- lcd.clear();
- }
- case MODUL5:
- {
- lcd.clear();
- }
- case MODUL6:
- {
- lcd.clear();
- }
- case MODUL7:
- {
- lcd.clear();
- }
- case MODUL8:
- {
- lcd.clear();
- }
- case MODUL9:
- {
- lcd.clear();
- }
- case MODUL10:
- {
- lcd.clear();
- }
- case MODUL11:
- {
- lcd.clear();
- }
- case ZENTRALE:
- {
- lcd.clear();
- }
- }
- akt_state_LCDANZEIGE = next_state_LCDANZEIGE; // -----------------Zustand Next in Zustand aktuell schreiben
- }
- switch (akt_state_LCDANZEIGE) // Eigentliche State mschine für die verschiedenen ANzeigen am LCD
- {
- case MODUL1:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-1 Wendel Sud");
- lcd.setCursor(0, 1);
- lcd.print("Keine Daten!");
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL2;
- delay(250);
- }
- break;
- }
- case MODUL2:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-2 SBH Sud Einfahrt");
- lcd.setCursor(0, 1);
- lcd.print("LS-Einf= ");
- lcd.print(LSEinfahrtSBHSudState);
- lcd.setCursor(0, 2);
- lcd.print("LS-VMAX= ");
- lcd.print(LSVmaxSBHSudState);
- lcd.setCursor(0, 3);
- lcd.print("LS-Wende= ");
- lcd.print(LSEinfahrtWendelSudState);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL3;
- delay(250);
- }
- break;
- }
- case MODUL3:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-3 SBH Sud Rechts");
- lcd.setCursor(0, 1);
- lcd.print("Gleis 1=");
- lcd.print(LSEinfahrtSBHSudGleis1State);
- lcd.setCursor(10, 1);
- lcd.print("Gleis 2=");
- lcd.print(LSEinfahrtSBHSudGleis2State);
- lcd.setCursor(0, 2);
- lcd.print("Gleis 3=");
- lcd.print(LSEinfahrtSBHSudGleis3State);
- lcd.setCursor(10, 2);
- lcd.print("Gleis 4=");
- lcd.print(LSEinfahrtSBHSudGleis4State);
- lcd.setCursor(0, 3);
- lcd.print("Gleis 5=");
- lcd.print(LSEinfahrtSBHSudGleis5State);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL4;
- delay(250);
- }
- break;
- }
- case MODUL4:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-4 SBH Sud Links");
- lcd.setCursor(0, 1);
- lcd.print("Gleis 1=");
- lcd.print(LSEndposSBHSudGleis1State);
- lcd.setCursor(10, 1);
- lcd.print("Gleis 2=");
- lcd.print(LSEndposSBHSudGleis2State);
- lcd.setCursor(0, 2);
- lcd.print("Gleis 3=");
- lcd.print(LSEndposSBHSudGleis3State);
- lcd.setCursor(10, 2);
- lcd.print("Gleis 4=");
- lcd.print(LSEndposSBHSudGleis4State);
- lcd.setCursor(0, 3);
- lcd.print("Gleis 5=");
- lcd.print(LSEndposSBHSudGleis5State);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL5;
- delay(250);
- }
- break;
- }
- case MODUL5:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-5 SBH Sud Kehrschl");
- lcd.setCursor(0, 1);
- lcd.print("LS-Einf-Wende = ");
- lcd.print(LSEinfahrtKehrschleifeSBHSudState);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL6;
- delay(250);
- }
- break;
- }
- case MODUL6:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-6 Kreuzung");
- lcd.setCursor(0, 1);
- lcd.print("WeSBH = ");
- lcd.print(LSEinfahrtVonSBHWest1State);
- lcd.setCursor(10, 1);
- lcd.print("WeWen = ");
- lcd.print(LSEinfahrtVonSBHWest2State);
- lcd.setCursor(0, 2);
- lcd.print("SuSBH = ");
- lcd.print(LSEinfahrtVonSBHSudState);
- lcd.setCursor(10, 2);
- lcd.print("SuWen = ");
- lcd.print(LSEinfahrtVonWendelWestState);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL7;
- delay(250);
- }
- break;
- }
- case MODUL7:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-7 ");
- lcd.setCursor(0, 1);
- lcd.print("Keine Daten!");
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL8;
- delay(250);
- }
- break;
- }
- case MODUL8:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-8 SBH West Links");
- lcd.setCursor(0, 1);
- lcd.print("Gleis 1=");
- lcd.print(LSEndposSBHWestGleis1State);
- lcd.setCursor(10, 1);
- lcd.print("Gleis 2=");
- lcd.print(LSEndposSBHWestGleis2State);
- lcd.setCursor(0, 2);
- lcd.print("Gleis 3=");
- lcd.print(LSEndposSBHWestGleis3State);
- lcd.setCursor(10, 2);
- lcd.print("Gleis 4=");
- lcd.print(LSEndposSBHWestGleis4State);
- lcd.setCursor(0, 3);
- lcd.print("Gleis 5=");
- lcd.print(LSEndposSBHWestGleis5State);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL9;
- delay(250);
- }
- break;
- }
- case MODUL9:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-9 SBH West Rechts");
- lcd.setCursor(0, 1);
- lcd.print("Gleis 1=");
- lcd.print(LSEinfahrtSBHWestGleis1State);
- lcd.setCursor(10, 1);
- lcd.print("Gleis 2=");
- lcd.print(LSEinfahrtSBHWestGleis2State);
- lcd.setCursor(0, 2);
- lcd.print("Gleis 3=");
- lcd.print(LSEinfahrtSBHWestGleis3State);
- lcd.setCursor(10, 2);
- lcd.print("Gleis 4=");
- lcd.print(LSEinfahrtSBHWestGleis4State);
- lcd.setCursor(0, 3);
- lcd.print("Gleis 5=");
- lcd.print(LSEinfahrtSBHWestGleis5State);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL10;
- delay(250);
- }
- break;
- }
- case MODUL10:
- {
- lcd.setCursor(0, 0);
- lcd.print("M10 SBHWest Einfahrt");
- lcd.setCursor(0, 1);
- lcd.print("LS-Einf= ");
- lcd.print(LSEinfahrtSBHWestState);
- lcd.setCursor(0, 2);
- lcd.print("LS-VMAX= ");
- lcd.print(LSVmaxSBHWestState);
- lcd.setCursor(0, 3);
- lcd.print("LS-Wende= ");
- lcd.print(LSEinfahrtWendelWestState);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL11;
- delay(250);
- }
- break;
- }
- case MODUL11:
- {
- lcd.setCursor(0, 0);
- lcd.print("M-11 Wendel West");
- lcd.setCursor(0, 1);
- lcd.print("Keine Daten!");
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = ZENTRALE;
- delay(250);
- }
- break;
- }
- case ZENTRALE:
- {
- lcd.setCursor(0, 0);
- lcd.print("ZENTRALE ");
- lcd.setCursor(0, 1);
- lcd.print("Weiche Sud Einfa. =");
- lcd.print(WeicheEinfahrtSBHSudGeradeausState);
- lcd.setCursor(0, 2);
- lcd.print("Weiche Sud Glei.1 =");
- lcd.print(WeicheSBHSudGleis1geradeausState);
- NextAnzeigeState = digitalRead(NextAnzeige);
- if (NextAnzeigeState == 0)
- {
- next_state_LCDANZEIGE = MODUL1;
- delay(250);
- }
- break;
- }
- }
- }
- // ------------------------------------- Ansteuerung LCD 20x4 Ende
- // Eingänge auslesen
- {
- TestCAN1State = digitalRead(TestCAN1);
- if (TestCAN1State == 1)
- {
- WeicheEinfahrtSBHSudGeradeausState = 1;
- WeicheEinfahrtSBHSudAbbiegenState = 1;
- }
- else
- {
- WeicheEinfahrtSBHSudGeradeausState = 0;
- WeicheEinfahrtSBHSudAbbiegenState = 0;
- }
- // ---------------------------------
- TestCAN2State = digitalRead(TestCAN2);
- if (TestCAN2State == 1)
- {
- WeicheSBHSudGleis1geradeausState = 1;
- }
- else
- {
- WeicheSBHSudGleis1geradeausState = 0;
- }
- }
- // Ausgänge schalten
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment