UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« on: January 10, 2013, 07:02:34 pm » |
OK, I know this is something to do with a change in the cores somewhere.
I'm trying to compile and upload a sketch on a 1284P.
This sketch uploads fine to a 328(P) when Arduino Uno is selected as the board, but it's failing with my Bobuino pinmapped mighty1284P board.
I'm guessing it's because there needs to be some additional definition somewhere for this new INPUT_PULLUP method.
Any help is appreciated.
|
|
|
|
« Last Edit: January 12, 2013, 12:12:55 pm by tack »
|
Logged
|
|
|
|
|
Poole, Dorset, UK
Offline
God Member
Karma: 12
Posts: 776
|
 |
« Reply #1 on: January 10, 2013, 07:39:17 pm » |
Post the code and a link to the hardware you are using!.
Mark
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #2 on: January 10, 2013, 08:02:39 pm » |
This happens with just the Keypad_I2C examples, but is related to keypad.h It compiles fine if I choose Arduino Uno, but fails if I choose the 1284P Bobuino variant. G:\Drive_d\Data\Arduino\Arduino User Data\libraries\Keypad\Keypad.cpp: In member function 'bool Keypad::scanKeys()': G:\Drive_d\Data\\Arduino\Arduino User Data\libraries\Keypad\Keypad.cpp:86: error: 'INPUT_PULLUP' was not declared in this scope The sketch is below, but it's nothing in the sketch itself. It works fine on a 328P, whether proper Arduino or on a breadboard. I'm using IDE 1.01 /* @file CustomKeypad.pde || @version 1.0 || @author Alexander Brevig || @contact alexanderbrevig@gmail.com || || @description || | Demonstrates changing the keypad size and key values. || # Use with I2C i/o G. D. (Joe) Young Feb 28/12 */ #include <Keypad_I2C.h> #include <Keypad.h> // GDY120705 #include <Wire.h>
#define I2CADDR 0x20
const byte ROWS = 4; //four rows const byte COLS = 4; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad Keypad_I2C customKeypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS, I2CADDR);
void setup(){ // Wire.begin( ); customKeypad.begin( ); // GDY120705 Serial.begin(9600); } void loop(){ char customKey = customKeypad.getKey(); if (customKey != NO_KEY){ Serial.println(customKey); } }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #3 on: January 11, 2013, 03:01:05 am » |
The pins default to input, so if you just digitalWrite (pin, HIGH) that will have the same effect.
|
|
|
|
|
Logged
|
|
|
|
|
Kansas City area
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #4 on: January 11, 2013, 05:32:11 am » |
tack, The Mighty1284p core files lack that instruction. I've had great success using the standard core files with my 1284p boards for several months. Try the following change in the boards.txt file for your board: #bobuino.build.core=arduino:arduino bobuino.build.core=standard
Jon
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #5 on: January 11, 2013, 07:15:59 am » |
tack, The Mighty1284p core files lack that instruction. I've had great success using the standard core files with my 1284p boards for several months. Try the following change in the boards.txt file for your board: #bobuino.build.core=arduino:arduino bobuino.build.core=standard
Jon The boards.txt is already set to standard, as per above. The pins default to input, so if you just digitalWrite (pin, HIGH) that will have the same effect.
This is an error being received with a library, so it's not code in my sketch. I guess I could go and modify all the INPUT_PULLUP uses in the library to PinMode(pin, INPUT) and digitalWrite(pin, HIGH) but I was hoping there was a more elegant solution, such as updating the mighty1284P core files so I don't have to change the library every time an update is released.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 15
Posts: 463
|
 |
« Reply #6 on: January 11, 2013, 09:42:40 am » |
The boards.txt is already set to standard, as per above. The pins default to input, so if you just digitalWrite (pin, HIGH) that will have the same effect.
This is an error being received with a library, so it's not code in my sketch. I guess I could go and modify all the INPUT_PULLUP uses in the library to PinMode(pin, INPUT) and digitalWrite(pin, HIGH) but I was hoping there was a more elegant solution, such as updating the mighty1284P core files so I don't have to change the library every time an update is released. What if you just do this: #ifndef INPUT_PULLUP #define INPUT_PULLUP 2 #endif
?????
|
|
|
|
|
Logged
|
|
|
|
|
Austin, TX
Offline
Faraday Member
Karma: 42
Posts: 5248
CMiYC
|
 |
« Reply #7 on: January 11, 2013, 10:38:13 am » |
Does your 1284 variant use its own cores directory: "/Java/hardware/arduino/cores/"?
in /Java/hardware/arduino/cores/arduino/wiring_digital.c there is an if-condition for INPUT_PULLUP (which turns on the internal pull-ups)
while INPUT_PULLUP is #defined in Arduino.h.
If your variant has its own "cores" directory, you may need to add the code from wiring.digital.c's pinMode and the #define from Arduino.h.
This was added in 1.01 or 1.02.
|
|
|
|
|
Logged
|
|
|
|
|
Phillipsburg, NJ
Online
Full Member
Karma: 6
Posts: 141
Author: Matrix Keypad Library
|
 |
« Reply #8 on: January 11, 2013, 06:59:25 pm » |
Hi tack, This is an error being received with a library, so it's not code in my sketch. I guess I could go and modify all the INPUT_PULLUP uses in the library to PinMode(pin, INPUT) and digitalWrite(pin, HIGH) but I was hoping there was a more elegant solution, such as updating the mighty1284P core files so I don't have to change the library every time an update is released.
If you don't mind running a quick test for me... Change line 46 in keypad.h from: #if defined(ARDUINO) && ARDUINO < 101 to: #if !defined INPUT_PULLUP And see if it works for you. If so then I will update the library so you won't have to mess around with it. -Mark Stanley
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #9 on: January 12, 2013, 11:36:49 am » |
Mark, I'll give that a try for you shortly.
What I had done as a quick fix was alter the arduino.h file, in my 1284P cores folder, to add #define INPUT_PULLUP 0x02
I'm guessing it was dirty though as there is probably some code in another file (like suggested with wiring.h) where INPUT_PULLUP is mapped to the two normal pinMode and digitalWrite operations.
I'll remove the line and try your fix and report back. If it works then it would fix it for all permutations, whether the 1284P cores get fully updated or not. It'll either be fixed in the cores and your fix doesn't take effect, or your fix covers it if no INPUT_PULLUP defined.
I'll report back shortly.
Many thanks for taking the time to respond and PM me that you had done so.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #10 on: January 12, 2013, 12:12:21 pm » |
OK, this certainly seems to fix the error. As explained in my response to your PM, I had applied a fix in my 1284P arduino.h file. I removed that and tried compiling and got the original error. I then added the keypad.h fix like this //#if defined(ARDUINO) && ARDUINO < 101 #ifndef INPUT_PULLUP // fix for MCU with custom bootloaders/cores that don't have the update, like 1284P #define INPUT_PULLUP INPUT #endif This now compiles fine with the following custom MCU entries:- Mighty1284P with Optiboot, using maniacbug, bobuino and avrdude variants Custom 644P with Optiboot, using bobuino variant
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 336
Posts: 36463
Seattle, WA USA
|
 |
« Reply #11 on: January 12, 2013, 12:17:37 pm » |
It compile OK, but it doesn't do the same thing. All you have accomplished there is to make INPUT_PULLUP equivalent to INPUT. The _PULLUP extension is lost.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #12 on: January 12, 2013, 12:21:08 pm » |
I then added the keypad.h fix like this It masks the problem, not solving the problem. I would change the code: whenever it uses INPUT_PULLUP, explicitly writes a '1' to the pin.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #13 on: January 12, 2013, 12:27:03 pm » |
It compile OK, but it doesn't do the same thing. All you have accomplished there is to make INPUT_PULLUP equivalent to INPUT. The _PULLUP extension is lost.
Ah, I understand. So all it does is change a written pinMode(pin, INPUT_PULLUP); to pinMode(pin, INPUT); But the internal pullup isn't enabled. OK, so how about an actual fix to the cores? In arduino.h I do #define INPUT_PULLUP 0x20 and in wiring_digital.c under the pinMode(uint8_t pin, uint8_t mode) function I change if (mode == INPUT) { uint8_t oldSREG = SREG; cli(); *reg &= ~bit; SREG = oldSREG; } else { uint8_t oldSREG = SREG; cli(); *reg |= bit; SREG = oldSREG; } To if (mode == INPUT) { uint8_t oldSREG = SREG; cli(); *reg &= ~bit; *out &= ~bit; SREG = oldSREG; } else if (mode == INPUT_PULLUP) { uint8_t oldSREG = SREG; cli(); *reg &= ~bit; *out |= bit; SREG = oldSREG; } else { uint8_t oldSREG = SREG; cli(); *reg |= bit; SREG = oldSREG; } The only difference I can see is the reference to *out pointer, so I'm not 100% sure if that is a new variable somewhere else?
|
|
|
|
« Last Edit: January 12, 2013, 12:29:19 pm by tack »
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 9
Posts: 356
|
 |
« Reply #14 on: January 12, 2013, 12:32:12 pm » |
TBH, do I need to do anything unless I actually add code, or use libraries that make use of the INPUT_PULLUP option.
As far as I can see, keypad.h doesn't do that as it already had that masking of the issue for pre 1.0.
OR, are there other 'if defined(ARDUINO) && ARDUINO < 101' that make use of INPUT_PULLUP when the IDE version is 1.0 or above?
|
|
|
|
|
Logged
|
|
|
|
|
|