question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

digispark/digistump ATTINY85 board keyboard compile errors

See original GitHub issue
[env:digispark-tiny]
platform = atmelavr
board = digispark-tiny
framework = arduino

src/keyboard.cpp:

#include "DigiKeyboard.h"

void setup() {
  DigiKeyboard.update();
}

void loop() {
  delay(1000);

  DigiKeyboard.update();
  delay(100);

  DigiKeyboard.print("hello");
  DigiKeyboard.println("world");

  delay(5000);
}
$ platformio run --target upload
Processing digispark-tiny (platform: atmelavr; board: digispark-tiny; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/digispark-tiny.html
PLATFORM: Atmel AVR > Digispark USB
SYSTEM: ATTINY85 16MHz 512B RAM (5.87KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 48 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <DigisparkKeyboard>
Compiling .pioenvs/digispark-tiny/src/keyboard.cpp.o
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/oddebug.c.o
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/osccal.c.o
In file included from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Stream.h:24:0,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/TinyDebugSerial.h:31,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/WProgram.h:18,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Arduino.h:4,
from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:10,
from src/keyboard.cpp:1:
~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Print.h:37:0: warning: "BIN" redefined
#define BIN 2
^
In file included from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/iotn85.h:38:0,
from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/io.h:428,
from ~/.platformio/packages/toolchain-atmelavr/avr/include/avr/interrupt.h:38,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/WProgram.h:8,
from ~/.platformio/packages/framework-arduinoavr/cores/digispark_tiny/Arduino.h:4,
from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:10,
from src/keyboard.cpp:1:
~/.platformio/packages/toolchain-atmelavr/avr/include/avr/iotnx5.h:55:0: note: this is the location of the previous definition
#define BIN     7
^
In file included from ~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:13:0,
from src/keyboard.cpp:1:
~/.platformio/packages/toolchain-atmelavr/avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>." [-Wcpp]
#warning "This file has been moved to <util/delay.h>."
^
Compiling .pioenvs/digispark-tiny/lib379/DigisparkKeyboard/usbdrv.c.o
In file included from src/keyboard.cpp:1:0:
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '161' from 'int' to 'char' inside { } [-Wnarrowing]
};
^
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '231' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
*** [.pioenvs/digispark-tiny/src/keyboard.cpp.o] Error 1
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/osccal.c: In function 'calibrateOscillator':
~/.platformio/packages/framework-arduinoavr/libraries/__cores__/digispark/DigisparkKeyboard/osccal.c:34:13: warning: implicit declaration of function 'usbMeasureFrameLength' [-Wimplicit-function-declaration]
x = usbMeasureFrameLength();    /* proportional to current real frequency */
^
==================================================================== [ERROR] Took 1.12 seconds ====================================================================

Which looks like 3 issues:

  1. redefinition of BIN with different values
  2. deprecated inclusion of delay.h which should be util/delay.h
  3. conversion of from ‘int’ to ‘char’ inside { }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

6reactions
zaypencommented, Aug 13, 2020

As of 2020-08-14, having the same issue 😂 alternative fix besides @bryanjhv 's, add this line to platformio.ini

build_flags = -Wno-error=narrowing
4reactions
ekrempelcommented, Dec 27, 2018

Many thanks for your tip. I was able to compile and deploy the coded after I modified the code as follows.

const PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */

  (char) 0x05, (char) 0x01,                    // USAGE_PAGE (Generic Desktop)
  (char) 0x09, (char) 0x06,                    // USAGE (Keyboard)
  (char) 0xa1, (char) 0x01,                    // COLLECTION (Application)
  (char) 0x05, (char) 0x07,                    //   USAGE_PAGE (Keyboard)
  (char) 0x19, (char) 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)
  (char) 0x29, (char) 0xe7,                    //   USAGE_MAXIMUM (Keyboard Right GUI)
  (char) 0x15, (char) 0x00,                    //   LOGICAL_MINIMUM (0)
  (char) 0x25, (char) 0x01,                    //   LOGICAL_MAXIMUM (1)
  (char) 0x75, (char) 0x01,                    //   REPORT_SIZE (1)
  (char) 0x95, (char) 0x08,                    //   REPORT_COUNT (8)
  (char) 0x81, (char) 0x02,                    //   INPUT (Data,Var,Abs)
  (char) 0x95, (char) 0x01,           //   REPORT_COUNT (simultaneous keystrokes)
  (char) 0x75, (char) 0x08,                    //   REPORT_SIZE (8)
  (char) 0x25, (char) 0x65,                    //   LOGICAL_MAXIMUM (101)
  (char) 0x19, (char) 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))
  (char) 0x29, (char) 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)
  (char) 0x81, (char) 0x00,                    //   INPUT (Data,Ary,Abs)
  (char) 0xc0                           // END_COLLECTION
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

DigiSpark AT Tiny85 compile problem?
The resulting code compiles fine for me with the digispark core ... in the Attiny85 section of the file arduino_folder/packages/digistump/ ...
Read more >
Weird error I cant find an answer for? [solved] - Arduino Forum
I am using the attiny85 to create a rickroll but I am having many many errors some of which include Error compiling for...
Read more >
Compilation error with DigiKeyboard.h - Digistump
I'm using digispark attiny85 and tried some basic code like led blinking and it ... Error compiling for board Digispark (Default - 16.5mhz)....
Read more >
DigiKeyboard and Bluetooth. - Digistump
And now, here is the error I am getting compiling. ... Arduino: 1.6.6 (Linux), Board: "Digispark (Default - 16.5mhz)"
Read more >
Memory overload using keyboard library - Digistump
When I upload it to the digispark, it will work as long as I dont add any ... The weird thing here is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found