all years
202620242023202220212020201920182017201620152014
2211152313307215210213462
newer 3 / 4 older

FAME BOY | A bit of a hmpf moment

2018-03-20 16:25:46

on the 13th of May the winners of the BOM  auditions were announced - on the 23rd the parts are expected to arrive here in Germany (send today, national winner packets were send on last friday). My plastics for the screen bezel were supposed to arrive last friday, hopefully it will get here on thursday. Ebay decided to redirect it to my parents place, so we had to resend it cause the dropoff place is open from 10 to 4... argh. I'm trying to print ABS now, seems like I have killed the hotend with the attempt to print with PLA. 

Meh.

FAME BOY | feels a bit empty, for reasons

2018-03-18 18:54:11

There was an unofficial statement of "bonus points for blog posts" on the element14 community page for the "Hack Like Heck" contest, so that's why I'm posting my logs there and I'm too lazy to copy them over here. Wouldn't feel right either, so I admit to being lazy.

Here's what I have so far:

FAME BOY - build log 1 - Hack Like Heck

FAME BOY - build log 2 - Hack Like Heck

FAME BOY - build log 3 - Hack Like Heck

FAME BOY - build log 4 - Hack Like Heck

LAMEBOY - another ESP12 handheld | LameBoy MQTT pager aka LameQuix [by @woodworker]

2018-03-18 00:52:04

The Idea

I've wanted to build myself a small MQTT based message reader like those majestic 90s pagers everybody lusted after back then and I have a Lameboy.
So I knew what i had to do.

This "mod" does consist of 2 parts, a little hardware upgrade and a very small firmware.

---------- more ----------

The Hardware

All we need is an NPN-transistor and a small vibration motor (+ something to glue it to the Lameboy)

The Lameboy has 2 visible Action Buttons, the A and B button. But there is also a C button hidden on the backside/inside of your little Lameboy and thanks
to the magic of the I/O expander used, this button will be an OUTPUT!!!!

We add an NPN Transistor with its base connected to the C-Button pad, collector to 3.3V and the emitter to the positive side of our vibration motor. And the negative side of the motor we just solder to ground.

The Software

/**
 *  _                           ____        _      
 * | |                         / __ \      (_)     
 * | |     __ _ _ __ ___   ___| |  | |_   _ ___  __
 * | |    / _` | '_ ` _ \ / _ \ |  | | | | | \ \/ /
 * | |___| (_| | | | | | |  __/ |__| | |_| | |>  < 
 * |______\__,_|_| |_| |_|\___|\___\_\\__,_|_/_/\_\
 */

#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>
#include <PubSubClient.h>

uint32_t bat = 4200;
Adafruit_PCD8544 display = Adafruit_PCD8544(2, 15, 0);

#define BUTTON_UP    B10000000
#define BUTTON_DOWN  B00100000
#define BUTTON_LEFT  B01000000
#define BUTTON_RIGHT B00010000
#define BUTTON_B     B00000100
#define BUTTON_A     B00001000
#define BUTTON_SD    B00000010

#define MESSAGE_LENGTH    100
#define MAX_MESSAGES        4

boolean bottonU_pressed = false;
boolean bottonD_pressed = false;
boolean bottonL_pressed = false;
boolean bottonR_pressed = false;
boolean bottonA_pressed = false;
boolean bottonB_pressed = false;
boolean bottonSD_pressed = false;

boolean bottonU_last_pressed = false;
boolean bottonD_last_pressed = false;
boolean bottonL_last_pressed = false;
boolean bottonR_last_pressed = false;
boolean bottonA_last_pressed = false;
boolean bottonB_last_pressed = false;
boolean bottonSD_last_pressed = false;

boolean bottonU_changed = false;
boolean bottonD_changed = false;
boolean bottonL_changed = false;
boolean bottonR_changed = false;
boolean bottonA_changed = false;
boolean bottonB_changed = false;
boolean bottonSD_changed = false;

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqtt_server = "your.mqtt.server";

const char* readChannel = "inTopic";
const char* writeChannel = "outTopic";

WiFiClient espClient;
PubSubClient client(espClient);

char msg[100];

long lastMsg = 0;
int showMessage = 0;
int messageCount = 0;
char lastmsg[MAX_MESSAGES][MESSAGE_LENGTH];

bool hasMessage = false;
bool hasRead = true;

int value = 0;

void setup()
{
  Serial.begin(115200);
  Wire.begin();

  Wire.beginTransmission(0x38);
  Wire.write(B11111110);
  Wire.endTransmission();

  setBackgroundColor('c', 200,200,200);

  display.begin();
  display.clearDisplay();
  display.setRotation(2);
  display.setContrast(58);
  display.display();

  setBackgroundColor('n', 255, 100, 100);
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.setTextColor(BLACK);
  display.println("OH HI!");
  display.display();
  delay(2000);

  display.setTextColor(BLACK, WHITE);
  display.setTextSize(1);

  setup_wifi();
  
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");

  if (messageCount < MAX_MESSAGES) {
    messageCount++;
  }

  ///// lastmsg buffer change
  for (int k = MAX_MESSAGES - 1; k > 0; k--) {
    for(int l = 0; l < MESSAGE_LENGTH; l++) {
      lastmsg[k][l] = lastmsg[k-1][l];
    }
  }

  for(int j = 0; j < MESSAGE_LENGTH; j++) {
    lastmsg[0][j] = NULL;
  }
  
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
    if (i < MESSAGE_LENGTH) {
      lastmsg[0][i] = (char)payload[i];
    }
  }
  hasMessage = true;
  hasRead = false;
  showMessage = 0;
  Serial.println();
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP8266Client")) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish(writeChannel, "hello world");
      // ... and resubscribe
      client.subscribe(readChannel);
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void loop() 
{
  read_buttons();
  
  display.clearDisplay();

  // show selected message
  display.print("Msg #");
  display.print((showMessage + 1));
  display.print("/");
  display.print(messageCount);
  
  // show battery voltage
  uint32_t aIn = analogRead(A0);
  aIn = map(aIn, 0, 1024, 0, 4400); 
  bat = (aIn+bat)/2;
  display.print("  ");
  display.println(bat);

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  // print selected message
  display.print(lastmsg[showMessage]);
  display.println("");

  // backlight on in case of unread message
  if (hasRead) {
    setBackgroundColor('n', 0, 0, 0);
  } else {
    setBackgroundColor('n', 255, 100, 100);
  }

  // notify for new message
  if (hasMessage) {
    vibrate(200);
    hasMessage = false;
  }

  // scroll messages down
  if (bottonD_pressed && bottonD_changed) {
    if (showMessage < ( MAX_MESSAGES - 1) ) {
      showMessage++;
    }
  }

  // scroll messages up
  if (bottonU_pressed && bottonU_changed) {
    if (showMessage > 0) {
      showMessage--;
    }
  }
  
  // mark message read
  if (bottonB_pressed) {
    if (showMessage == 0) {
      hasRead = true;
    }
  }

  // send message
  if (bottonA_pressed && bottonA_changed) {
    ++value;
    snprintf (msg, 75, "hello world #%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish(writeChannel, msg);
    vibrate(100);
  }
  
  display.display();
  delay(100);
}

void vibrate(int milli) {
    Wire.beginTransmission(0x38);
    Wire.write(B11111111);
    Wire.endTransmission();

    delay (milli);
    
    Wire.beginTransmission(0x38);
    Wire.write(B11111110);
    Wire.endTransmission();
}

void setBackgroundColor(char c, int r, int g, int b)
{
  // c is fade to color, n is now color
  Wire.beginTransmission(0x80);
  Wire.write(c);
  Wire.write(r);
  Wire.write(g);
  Wire.write(b);
  Wire.endTransmission();
}

void read_buttons()
{
  Wire.requestFrom(0x38, 1);
  byte data = Wire.read();
  bottonU_pressed = (~data & BUTTON_UP) > 0;
  bottonD_pressed = (~data & BUTTON_DOWN) > 0;
  bottonL_pressed = (~data & BUTTON_LEFT) > 0;
  bottonR_pressed = (~data & BUTTON_RIGHT) > 0;
  bottonA_pressed = (~data & BUTTON_A) > 0;
  bottonB_pressed = (~data & BUTTON_B) > 0;
  bottonSD_pressed = (~data & BUTTON_SD) > 0;

  bottonU_changed = bottonU_last_pressed != bottonU_pressed;
  bottonD_changed = bottonD_last_pressed != bottonD_pressed;
  bottonL_changed = bottonL_last_pressed != bottonL_pressed;
  bottonR_changed = bottonR_last_pressed != bottonR_pressed;
  bottonA_changed = bottonA_last_pressed != bottonA_pressed;
  bottonB_changed = bottonB_last_pressed != bottonB_pressed;
  bottonSD_changed = bottonSD_last_pressed != bottonSD_pressed;
  
  bottonU_last_pressed = bottonU_pressed;
  bottonD_last_pressed = bottonD_pressed;
  bottonL_last_pressed = bottonL_pressed;
  bottonR_last_pressed = bottonR_pressed;
  bottonA_last_pressed = bottonA_pressed;
  bottonB_last_pressed = bottonB_pressed;
  bottonSD_last_pressed = bottonSD_pressed;
}

Now i have my very own small and simple MQTT based pager \o/

electric hurdy gurdy synthy | 3d printing stuff

2018-03-17 11:56:51

currently printing all of this, I already forgot the tooth count and ratio of the gear box, but I think it's something like 1:5 or 1:6. Or maybe it was 1:10. Reminds me a bit of my #Locomatrix - 3D POV - a different approach 

electric hurdy gurdy synthy | I've bought a brushless motor

2018-03-15 19:17:45

now what? I need to do some experiments, find out what speeds I need, what kind of gearboxes make sense etc to get the most our of the motor. There are chips like LM74670 that together with a MOSFET can replace diodes for creating a rectifier. First thing that needs to be done is a small gearbox and crank. 

The LT4320 (I'd need three of them) is around 6 Euros each. Ouch.

http://www.eenewseurope.com/news/low-loss-3-phase-ideal-diode-bridge-rectifier-reference-design-0

LAMEBOY - another ESP12 handheld | Arduino skeleton script

2018-03-14 12:23:42

no wifi, 4 stars.

#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>

uint32_t bat = 4200;
Adafruit_PCD8544 display = Adafruit_PCD8544(2, 15, 0);

#define BUTTON_UP    B10000000
#define BUTTON_DOWN  B00100000
#define BUTTON_LEFT  B01000000
#define BUTTON_RIGHT B00010000
#define BUTTON_A     B00000100
#define BUTTON_B     B00001000
#define BUTTON_C     B00000001
#define BUTTON_SD    B00000010

boolean bottonU_pressed = false;
boolean bottonD_pressed = false;
boolean bottonL_pressed = false;
boolean bottonR_pressed = false;
boolean bottonA_pressed = false;
boolean bottonB_pressed = false;
boolean bottonC_pressed = false;
boolean bottonSD_pressed = false;

void setup()
{
  
  Serial.begin(115200);
  Wire.begin();
  setBackgroundColor('c', 200,200,200);
  
  display.begin();
  display.clearDisplay();
  display.setRotation(2);
  display.setContrast(58);
  display.display();

  setBackgroundColor('n', 255, 100, 100);
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.setTextColor(BLACK);
  display.println("OH HI!");
  display.display();
  delay(2000);

  setBackgroundColor('c', 200 ,200, 200);
  display.setTextColor(BLACK, WHITE);
  display.setTextSize(1);
  
}

void loop() 
{
  read_buttons();
  display.clearDisplay();
  uint32_t aIn = analogRead(A0);
  aIn = map(aIn, 0, 1024, 0, 4400); 
  bat = (aIn+bat)/2;
  display.println(bat);
  if (bottonU_pressed) display.println("U");
  if (bottonD_pressed) display.println("D");
  if (bottonL_pressed) display.println("L");
  if (bottonR_pressed) display.println("R");
  if (bottonA_pressed) display.println("A");
  if (bottonB_pressed) display.println("B");
  if (bottonC_pressed) display.println("C");
  if (bottonSD_pressed) display.println("SD");
  display.display();
  delay(25);
}

void setBackgroundColor(char c, int r, int g, int b)
{
  // c is fade to color, n is now color
  Wire.beginTransmission(0x80);
  Wire.write(c);
  Wire.write(r);
  Wire.write(g);
  Wire.write(b);
  Wire.endTransmission();
}

void read_buttons()
{
  Wire.requestFrom(0x20, 1);
  byte data = Wire.read();
  bottonU_pressed = (~data & BUTTON_UP) > 0;
  bottonD_pressed = (~data & BUTTON_DOWN) > 0;
  bottonL_pressed = (~data & BUTTON_LEFT) > 0;
  bottonR_pressed = (~data & BUTTON_RIGHT) > 0;
  bottonA_pressed = (~data & BUTTON_A) > 0;
  bottonB_pressed = (~data & BUTTON_B) > 0;
  bottonC_pressed = (~data & BUTTON_C) > 0;
  bottonSD_pressed = (~data & BUTTON_SD) > 0;
}

FAME BOY | weeeeeeeeeeeee

2018-03-13 23:52:50

https://www.element14.com/community/docs/DOC-88945/l/winners-announcement-free-bom-kits-for-hack-like-heck

WIFI Game Boy Cartridge | from the hackchat

2018-03-09 17:24:26

Me: I have this project idea: #WIFI Game Boy Cartridge - I was a bit naive when I started this, tried to toggle pin for pin but it was way too slow. Would/could this work with the I2S parallel interface? I wasn't able to find much on the I2S interface when I started this and what I found was above my skill set, but I still like the idea of having a cartridge that has wifi.

Sprite_tm says:4:31 PM
Ah, I saw that. Did something like that on a Vectrex with a CortexM4.

Sprite_tm says:4:32 PM
Wrt the WiFi GB cartridge: Long story short, I don't thing I2S is the right way to go there.

Me: okay, any right ways?

Sprite_tm says:4:33 PM
The issue mostly is that you need to see that a CS line goes low, then immediately read the address lines, look up whatever you want to send back and send it.

Sprite_tm says:4:34 PM
I think that I2S would be too slow for that; you'd have to set up a transaction and everything. I think you could get it to work if you wrote a high-prio interrupt for the CS pin, then in the interrupt handler, in assembly, read the address GPIOs as fast as you can, grab a response from internal memory (which luckily you have more than enough of) and send that to the data pins.

Sprite_tm says:4:35 PM
If you need help with that, poke me; by now I have some experience with high-level interrupts and I'm actually curious if the ESP32 can do it, but don't really have any interesting consoles here.

Me: I thought "as fast as I can" would be I2S, since there's no way of getting pins parallel

Sprite_tm says:4:37 PM
You might get it to work... but there's a fair amount of setup using the I2S peripheral. It may still be quicker than doing it manually, I agree.

Sprite_tm says:4:39 PM
@davedarko Maybe a good idea to move on to other qs... if there is still time at the end, I'd love to come back to it. For now, feel free to poke me at [mail] for this.


http://esp-idf.readthedocs.io/en/latest/api-guides/hlinterrupts.html

Hack Like Heck Audition Tape

2018-03-04 17:44:18

Had some fun today :) find out more about the contest(?) 

https://www.element14.com/community/community/experts/benheck/hack-like-heck

revamped my personal website

2018-03-03 20:18:43

well, who needs one anyways? I plan on backing up stuff from here with the help of the API. My old content is converted to the new "engine". Everything is now backed up in github, I have version control and am able to rework some content.

I also want to make a #LAMEBOY - another ESP12 handheld  page with all the important infos.


page link: www.davedarko.com

source code: https://github.com/davedarko/davedarkocom

LAMEBOY - another ESP12 handheld | customised spacehuhn case

2018-02-25 17:11:21

I've used a 3D printing pen to test if I could do some inlays with that - I think it worked out reasonably well :)

LAMEBOY - another ESP12 handheld | CircuitPython on the Lameboy

2018-02-23 09:25:42

Here are some commands you need to get started to install circuit python and snake on @ɖҿϝիɟթվ s #PewPew FeatherWing engine. How awesome is that :) You can also follow along Radomir's description, which is way better. 

https://hackaday.io/project/21578-pewpew-featherwing/log/100304-lameboy-playing-pewpew-games

sudo esptool.py -p /dev/cu.wchusbserial1410 erase_flash
sudo esptool.py -p /dev/cu.wchusbserial1410 --baud 115200 write_flash --flash_size=detect 0 adafruit-circuitpython-feather_huzzah-2.2.3.bin

// deactivate esp debug to serial
import esp; esp.osdebug(None)

ampy -p /dev/cu.wchusbserial1420 ls
ampy -p /dev/cu.wchusbserial1420 put lameboy.py
ampy -p /dev/cu.wchusbserial1420 put pew.py
ampy -p /dev/cu.wchusbserial1420 put snake.py
ampy -p /dev/cu.wchusbserial1420 put menu.py
ampy -p /dev/cu.wchusbserial1420 put main.py

// in case of errors
import os; os.remove('main.py')

// change attiny i2c adress to allow coms
import lameboy; lameboy.i2c.writeto(0, b'A\x0d\xd0\x0d\x0d')

sloth badge | new design!

2018-02-20 23:59:57

After a fallout with pimoroni I'm no longer allowed to use the sloth badge design. So here is the new design:

Just kidding! I've bought a soic8 adapter that I will solder into place and make this a dedicated SOIC8 programmer for the kit chips! I haven't heard from pimoroni in a while though, need to ping them in a tweet some time.

LAMEBOY - another ESP12 handheld | Changing the address of the Attiny

2018-02-20 22:17:12

[UPDATE] I've soldered up another Lameboy and checked the behaviour in Arduino, tried sending data to 0x0d but nothing happened. I've then set the address to 0x0d and it works with that address. Seems like it won't be written to the EEPROM on init but later checks the EEPROM for an address. (btw., I've edited the range for scanning from 1-255 to 0-127). It's probably still a different experience with python. 

Thanks to Radomir @ɖҿϝիɟթվ  who read through the cyz_rgb code and found the procedure, it's now possible to set the adress of the blinkM clone to a "real" legal value. This is how you'd do that in Arduino. After that it's stored into the EEPROM of the attiny. I'll do that for the next kits that go out.

void setAdress(byte a)
{
  // A X D0 0D X
  Wire.beginTransmission(0x00);
  Wire.write('A');
  Wire.write(a);
  Wire.write(0xd0);
  Wire.write(0x0d);
  Wire.write(a);
  Wire.endTransmission();
}

LAMEBOY - another ESP12 handheld | R3.1 boards in the wild

2018-02-20 09:55:04

So before I started selling on @Tindie , I was sending off a kit to @ɖҿϝիɟթվ  and I forgot to send him a crystal with that kit / check all the content before sending. There are also two fully assembled versions out there now, one has an ESP chip with 2MB flash instead of 4MB. From then on every ESP12 module is checked before sending. 

So here's rule number one:

Use the checklist and check if every part is in the kit. Obviously.

Known issues number one is the enable pin of the power regulator is floating, you need to botch the 10k to the switch. 

I will modify all future / rest of the pcbs so it's clear where to put it

There is no test program that greats you with a "hooray, you've made it". 

flash the ESP with a basic code, flash RGB lights, check buttons and display
Change the I2C address of the attiny before shipping

to be continued...

team badge idea | protoboard draft

2018-02-19 23:29:09

The ArduinoISP with all the LEDS, routed for soldering comfort, we'll fix that in software.

One of the four attiny45 Segments with IR communication.

The hole pcb.

sloth badge | current code, anyone any ideas to save space?

2018-02-19 11:28:26

I won't lie, this feels messy. This currently features 5 animations, where 2 of them are just "played accelerating" . 

Some things I'm not happy with:

 - the button does not work within the animations, so you need to push the button until the animation cycle is over

#include <avr/sleep.h>
#define nop() asm volatile("nop")
boolean leds_on = true;

byte badly_programmed_counter = 0;
byte animation_counter_max = 5;
byte animation_counter = 0;

// we need two frames with 8 bits for 12 LEDs
byte frame1 = 0;
byte frame2 = 0;

// animation where every third LED is glowing
// I could shift that continuosly and drop 4 bytes
const byte three_apart_length = 6;
const byte three_apart[three_apart_length] PROGMEM = {
  0b10010010, 0b01000000,
  0b01001001, 0b00100000,
  0b00100100, 0b10010000,
};

// this one is huge
// is there a math function to do that instead?
const byte updown_length = 14;
const byte updown[updown_length] PROGMEM = {
  0b00100000, 0b00000000,
  0b01010000, 0b00000000,
  0b10001000, 0b00000000,
  0b00000100, 0b00010000,
  0b00000010, 0b00100000,
  0b00000001, 0b01000000,
  0b00000000, 0b10000000,
};

// that's just blinking each led 
// maybe inverting the data bitwise does the trick
const byte two_apart_length = 4;
const byte two_apart[two_apart_length] PROGMEM = {
  0b10101010, 0b10100000,
  0b01010101, 0b01010000,
};

// should have taken a switch, sleep stuff is huge
ISR(INT0_vect) {
  sleep_disable();
  leds_on = true;
}

void setup()
{
  // this is for the button setup
  PORTB |= (1 << PB1);
  DDRB &= ~(1 << PB1);

  shutdown_chip();
}

void loop()
{
  if (leds_on)
  {
    cli();
    leds_on = false;

    // I call it that, because the millis stuff
    // and the interrupts collided and broke
    badly_programmed_counter = 0;
  }

  // fancy way of checking the button state
  if (!(PINB & (1 << PB1)))
  {
    badly_programmed_counter++;
    my_100ms_delay();

    // check if button was released before time
    // so animation index can be incremented
    // maybe a modulo with animation_counter_max
    // safes space
    if ( (PINB & (1 << PB1)) )
    {
      badly_programmed_counter = 0;
      animation_counter++;
      if (animation_counter == animation_counter_max)
      {
        animation_counter = 0;
      }
      charlie(animation_counter);

      // calling a function instead of writing it down
      // 5 times helps already
      for (byte b = 0; b < 5; b++) my_100ms_delay();
    }

    if (badly_programmed_counter >= 7)
    {
      // blink when shutdown is immanent
      for (byte b = 0; b < 5; b++) blip();
      shutdown_chip();
    }
  }
  else
  {
    animate_leds();
    badly_programmed_counter = 0;
  }
}

// this is probably already at it's best
void charlie (byte var) {
  leds_off();

  switch (var) {
    case 0: // 1
      DDRB |= (1 << PB0) | (1 << PB2); // output
      PORTB |= (1 << PB0); // HIGH
      break;
    case 1: // 2
      DDRB |= (1 << PB0) | (1 << PB2); // output
      PORTB |= (1 << PB2); // HIGH
      break;
    case 2: // 3
      DDRB |= (1 << PB2) | (1 << PB3); // output
      PORTB |= (1 << PB2); // HIGH
      break;
    case 3: // 4
      DDRB |= (1 << PB2) | (1 << PB3); // output
      PORTB |= (1 << PB3); // HIGH
      break;
    case 4: // 5
      DDRB |= (1 << PB3) | (1 << PB4); // output
      PORTB |= (1 << PB3); // HIGH
      break;
    case 5: // 6
      DDRB |= (1 << PB3) | (1 << PB4); // output
      PORTB |= (1 << PB4); // HIGH
      break;
    case 6: // 7
      DDRB |= (1 << PB0) | (1 << PB3); // output
      PORTB |= (1 << PB0); // HIGH
      break;
    case 7: // 8
      DDRB |= (1 << PB0) | (1 << PB3); // output
      PORTB |= (1 << PB3); // HIGH
      break;
    case 8: // 9
      DDRB |= (1 << PB2) | (1 << PB4); // output
      PORTB |= (1 << PB2); // HIGH
      break;
    case 9: // 10
      DDRB |= (1 << PB2) | (1 << PB4); // output
      PORTB |= (1 << PB4); // HIGH
      break;
    case 10: // 11
      DDRB |= (1 << PB0) | (1 << PB4); // output
      PORTB |= (1 << PB0); // HIGH
      break;
    case 11: // 12
      DDRB |= (1 << PB0) | (1 << PB4); // output
      PORTB |= (1 << PB4); // HIGH
      break;
    default:
      ;

      nop();
  }
}

void shutdown_chip()
{
  animation_counter = 0;
  leds_off();

  /* Clear WDRF in MCUSR */
  MCUSR &= ~(1 << WDRF);
  /* Write logical one to WDCE and WDE */
  /* Keep old prescaler setting to prevent unintentional time-out */
  WDTCR |= (1 << WDCE) | (1 << WDE);
  /* Turn off WDT */
  WDTCR = 0x00;

  ADCSRA &= ~(1 << ADEN); // turn off adc

  GIMSK |= (1 << INT0);
  GIMSK |= (1 << PCIE);

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sei(); // Enable global interrupts
  sleep_cpu();
  sleep_disable();
}

void animate_leds()
{
  switch (animation_counter)
  {
    case 0:
      animate_frames(
        three_apart_length,
        three_apart,
        512
      );
      break;

    case 1:
      for (byte acc_counter = 1; acc_counter < 64; acc_counter += 2)
      {
        animate_frames(
          three_apart_length,
          three_apart,
          acc_counter * 8
        );
      }
      break;

    case 2:
      animate_frames(
        updown_length,
        updown,
        512
      );
      break;

    case 3:
      animate_frames(
        two_apart_length,
        two_apart,
        2048
      );
      break;

    case 4:
      for (byte acc_counter = 1; acc_counter < 64; acc_counter += 2)
      {
        animate_frames(
          updown_length,
          updown,
          (63-acc_counter) * 4
        );
      }
      break;

    default:
      leds_off();
      break;
  }
}

void animate_frames(
  byte animation_length,
  const byte* animation_array,
  uint16_t frame_duration
) {
  for (byte i = 0; i < animation_length; i += 2)
  {
    // save the last time you blinked the LED
    frame1 = pgm_read_byte_near(animation_array + i);
    frame2 = pgm_read_byte_near(animation_array + i + 1);
    show_frame(frame_duration);
  }
}

// this just looks ugly, but needs to be done
// for loop through frame bytes to set the LEDs with 
// the charlie plex function
void show_frame(uint16_t byteframe_length)
{
  for (uint16_t j = 0; j < byteframe_length; j++)
  {
    //iterate through bit mask
    for (byte i = 0; i < 12; i++)
    {
      // if bitwise AND resolves to true
      if (
        (
          i < 8 &&
          1 << i & frame1
        ) ||
        (
          i > 7 &&
          1 << (i - 4) & frame2
        )
      )
      {
        charlie(i);
      }
      else
      {
        charlie(255);
      }
    }
  }
}

void leds_off()
{
  DDRB &= ~(0b00011101);
  PORTB &= ~(0b00011101);
}

void blip()
{
  charlie(11);
  // delay(100);
  my_100ms_delay();
  charlie(255);
  // delay(100);
  my_100ms_delay();
}

void my_100ms_delay()
{
  for (uint32_t i=0;i<40000;i++) nop();
}

LAMEBOY - another ESP12 handheld | the quest for sound

2018-02-15 12:55:00

I'm currently looking into getting a sound pin and the most likely candidate right now is the LCD reset pin. Did anyone ever had any problems not using the reset pin of the Nokia LCD? What could I test to make sure it works fine? worst case scenario is turning the lameboy on and off again, I guess. I could try using RX and TX for sound, where depending on the TX state the RX would emit sound (no modem noises while uploading if done right). But if I could free the RST pin for sound, then I could use the same idea for RX and TX to transmit IR maybe. Would be cool features to have, I think. 

Also to consider:

a "true" in system programmer | thoughts after half a year

2018-02-14 11:37:00

Overall I'm pretty happy with it, but I'm a bit sad that I can't use this with boards where pinheaders are already present. Would have been nice to have a standard 2x3 ISP socket on it and change between cables, pogopins and avr clamps. When it comes to power, a little regulator for 3V3 would be nice too. Basically switch between 5V, 3V3 and selfpowered. 

On the plus side, I'm using this quite heavily for my #K.I.T.T. - KNIGHT RIDER badge/brooch and #sloth badge, as well as unbricking the attiny on my #LAMEBOY - another ESP12 handheld 

K.I.T.T. - KNIGHT RIDER badge/brooch | 0603 revision of the code

2018-02-02 21:04:15

Recently on twitter Jon Raymond asked about a firmware update for the older versions of the badge. My hesitation was big until this point, since I thought the charlie-plexing would take up too much space alone, to integrate animations like I did with the newer 0805 version of this badge. As you can see here, I've logged a bit about the progress over on twitter https://twitter.com/davedarko/status/959491261903310848. 

I was able to put 7 animations onto the badge! If you want to try out some other animations on the push of a button, you now can! 



Download the hex - file from the download section and upload it to the attiny via:

#!/bin/bash
avrdude -c usbasp -p t13 -U lfuse:w:0x3A:m -U hfuse:w:0xFF:m -B 2000
avrdude -c usbasp -p t13 -U flash:w:KITTiny.ino_attiny13_9600000L.hex

You need to solder a button between the PB4 Pad and GND and find a good spot to glue it down. Have fun :)


slow chaser

fast chaser

K.I.T.T. persistance of vision (I'm really bad at this)

cross fader

cross fader beam

police flasher

computing (counting up in binary)

newer 3 / 4 older