@@ -43,9 +43,9 @@ Bugtton::Bugtton(const uint8_t a, const uint8_t *b, uint8_t mode, uint8_t dt){
4343
4444 // Create buttons (was first separate classes, but this is the way I went)
4545 _pins = new uint8_t [_count];
46- _bits = new byte [_count];
47- _stateStarted = new unsigned long [_count];
48- _ticksStarted = new unsigned long [_count];
46+ _bits = new uint8_t [_count];
47+ _stateStarted = new uint32_t [_count];
48+ _ticksStarted = new uint32_t [_count];
4949 // Init button data
5050 for (uint8_t i=0 ; i<_count; i++){
5151 setMode (b[i], mode);
@@ -69,7 +69,7 @@ void Bugtton::makeMasks(){
6969}
7070
7171// For debugging purposes
72- void Bugtton::printBIN (byte b){
72+ void Bugtton::printBIN (uint8_t b){
7373 for (int i = 7 ; i >= 0 ; i--)
7474 Serial.print (bitRead (b,i));
7575 Serial.println ();
@@ -146,9 +146,9 @@ void Bugtton::tickBit(uint8_t i, bool a) { bitWrite(_bits[i], 2, a); }
146146bool Bugtton::tickBit (uint8_t i) { return bitRead (_bits[i], 2 ); }
147147
148148// Timestamps for debounce, and duration function
149- void Bugtton::stateStarted (uint8_t i, unsigned long a){ _stateStarted[i] = a; }
150- unsigned long Bugtton::stateStarted (uint8_t i) { return _stateStarted[i]; }
151- unsigned long Bugtton::duration (uint8_t i) { return millis () - _stateStarted[i]; }
149+ void Bugtton::stateStarted (uint8_t i, uint32_t a){ _stateStarted[i] = a; }
150+ uint32_t Bugtton::stateStarted (uint8_t i) { return _stateStarted[i]; }
151+ uint32_t Bugtton::duration (uint8_t i) { return millis () - _stateStarted[i]; }
152152
153153// Set pin mode here
154154void Bugtton::setMode (uint8_t i, uint8_t mode){
@@ -213,7 +213,7 @@ bool Bugtton::held(uint8_t i){
213213}
214214
215215// Returns true once when <time> ms reached while button pressed state
216- bool Bugtton::heldUntil (uint8_t i, int t){
216+ bool Bugtton::heldUntil (uint8_t i, uint16_t t){
217217 // printBIN(_bits[i]);
218218 if ( (_bits[i]&B11111000) == B01000000 && duration (i) >= t) {
219219 bitWrite (_bits[i], 3 , 1 );
@@ -223,7 +223,7 @@ bool Bugtton::heldUntil(uint8_t i, int t){
223223}
224224
225225// Returns true once when <time> ms reached while button unpressed state
226- bool Bugtton::upUntil (uint8_t i, int t){
226+ bool Bugtton::upUntil (uint8_t i, uint16_t t){
227227 if ( (_bits[i]&B11111000) == B11100000 && duration (i) >= t) {
228228 bitWrite (_bits[i], 3 , 1 );
229229 return true ;
@@ -232,7 +232,7 @@ bool Bugtton::upUntil(uint8_t i, int t){
232232}
233233
234234// Returns true once every <time> ms
235- bool Bugtton::intervalTick (uint8_t i, unsigned long t){
235+ bool Bugtton::intervalTick (uint8_t i, uint32_t t){
236236 if ( (_bits[i]&B11110000) == B01000000){
237237 if ( (millis () - _ticksStarted[i]) >= t && !tickBit (i) ){
238238 tickBit (i, 1 );
0 commit comments