Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Logics does not work
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Logics does not work

by hangstrom on Thu Sep 03, 2020 10:11 am

Logics does not work with my Adafruit Feather M0 Adalogger
msTime = millis();
if (msTime > 2000) {
this line executes normally msTime is a unsigned long
}

msTime = millis();
if ((msTime > 2000) && (BolY)) {
this line never executes although the bool BolY is true
}

The same software works normal with Arduino Due
The developer is Arduino 1.8.13
My aim is also to use the Wire software

hangstrom
 
Posts: 2
Joined: Thu Sep 03, 2020 9:54 am

Re: Logics does not work

by hypercubed on Fri Sep 04, 2020 2:07 pm

Could you post full code?
What do you want it to do?

hypercubed
 
Posts: 4
Joined: Mon Jul 06, 2020 11:15 am

Re: Logics does not work

by hangstrom on Wed Sep 16, 2020 5:36 am

The logics on row 40-41 does not work.
I can get it work by shortening the switch-statement.

The purpose is to serial communicate with a display

Code: Select all | TOGGLE FULL SIZE
/*
  FeatherErr
 HEÅ 200916
 */
#include <SPI.h>
#define KeyPIN A5
#define VBATPIN A7
#define analog3 A3
#define PPin A2
#define TrigPin 13
#define CSB 5
#define RS 6
#define ResDisp 10
#define RW 11
int KeyVal = 0, KeyVal1 = 0, NoLoop, InitDispStep = 0;
float PVal, an3, Vbat,OutT;
char LastKey, KeyRes;
bool DispNotReady = true, DspChk;
long msTime, KeyDelT = 300, KeyRdStep = 50, KeyTime;
unsigned long LastKeyRdT = 0, InitDispT = 0;
// the setup function runs once when you press reset or power the board
void setup() {
  pinMode(TrigPin, INPUT_PULLUP); // Start log signal
  pinMode(8, OUTPUT);
  pinMode(TrigPin, OUTPUT);
  pinMode(CSB, OUTPUT);
  digitalWrite(CSB, LOW); //chip select low
  pinMode(RS, OUTPUT);
  digitalWrite(RS, LOW); //RS low
  pinMode(ResDisp, OUTPUT);
  digitalWrite(ResDisp, LOW); //Reset LOW, do reset
  pinMode(RW, OUTPUT);
  digitalWrite(RW, LOW); //R/W low
  Serial.begin(9600);
  SPI.begin();
}
// the loop function runs over and over again forever
void loop() {
  msTime = millis();
  DspChk = (bool) (msTime > 2000) && DispNotReady;
  if (DspChk){
    //Serial.println(msTime);
    InitDisp(); 
  }
}
void InitDisp(){
  Serial.println("Start Init display");
  Serial.println((msTime - InitDispT));
  if ((msTime - InitDispT)>=2){
    InitDispT = msTime;
    Serial.print("InitDispStep = ");
    Serial.println(InitDispStep); 
    switch (InitDispStep){
      case 0:
        //digitalWrite(ResDisp, HIGH); //Reset high
        break;
      case 1:
        //SPI.transfer(byte(0x31));// 8 bit, 1 line, instr. table 1
        break;
      case 2:
        //SPI.transfer(byte(0x14));//BS 1/5, 1 line
        break;
      case 3:
        //SPI.transfer(byte(0x55));//booster on, contrast C5, set C4
        break;
      case 4:
        //SPI.transfer(byte(0x6D));//set voltage follower and gain1
        break;
      case 5:
        //SPI.transfer(byte(0x7C));//set contrast C3, C2, C1
        break;
      case 6:
        //SPI.transfer(byte(0x30));//switch back to instruction table 0
        break;
      case 7:
        //SPI.transfer(byte(0x0F));//display on, cursor on, cursor blink
        break;
      case 8:
       //SPI.transfer(byte(0x01));//delete display, cursor at home
        break;
      case 9:
        //SPI.transfer(byte(0x06));//cursor auto-increment
        Serial.println("Inited display");
        DispNotReady = false;
        break;
      }
    InitDispStep += 1; 
  }
}
Attachments
FeatherErr.ino
(2.47 KiB) Downloaded 1 time
Last edited by adafruit_support_bill on Wed Sep 16, 2020 5:51 am, edited 1 time in total.
Reason: added code in-line

hangstrom
 
Posts: 2
Joined: Thu Sep 03, 2020 9:54 am

Please be positive and constructive with your questions and comments.