Skip to content
Kravitz Lab edited this page Jan 26, 2026 · 1 revision

FED4 Buttons Functionality

The FED4 has three user buttons (GPIO BUTTON_1 = 40, BUTTON_2 = 39, BUTTON_3 = 14), arranged bottom / middle / top. They use internal pull-down and can wake the device from light sleep. There is no general-purpose “button pressed” API for sketches; the library assigns fixed behaviors.

Default behavior (on wake)

  • checkButton1()Button 1 (bottom): Hold ~1 s → test pellet dispense (feed()), bopBeep().
  • checkButton2()Button 2 (middle): Hold ~1 s → device reset (red wipe, resetJingle(), esp_restart()).
  • checkButton3()Button 3 (top): Hold 500 msaudio toggle (silence / unsilence), plus click(). Hold 1500 msmenu (menu()), hapticDoubleBuzz().

These are run from wakeUp() after a button wake (not touch). Poll with digitalRead(BUTTON_1) etc. (HIGH = pressed) if you need raw state elsewhere (e.g. menu, dispense loop).

See FED4_Buttons.cpp, FED4_Pins.h.

FED4 Display (Screen) Functionality

The FED4 uses a Sharp Memory Display (SPI, DISPLAY_CS = 17), 144×168 pixels, 1-bit (black/white). The FED4 class extends Adafruit_GFX, so you can use standard GFX calls (drawPixel, fillRect, print, drawLine, etc.) plus FED4-specific helpers.

Initialization and refresh

  • initializeDisplay() — init display, allocate buffer, clear (called from begin()).
  • updateDisplay() — redraw status (task, mouse ID, env, battery, SD, counters, indicators, date/time). Called from run() and elsewhere.
  • refresh() — push the backing buffer to the display. Call after drawing.
  • clearDisplay() — clear buffer (white) and refresh.

Status helpers (used by updateDisplay)

  • displayTask(), displayMouseId(), displayEnvironmental(), displayBattery(), displaySDCardStatus(), displayCounters(), displayIndicators(), displayDateTime() — status layout.
  • displayActivityMonitor() / displayActivityCounters() — when program is ActivityMonitor.
  • displayInitStatus(msg) — show init message during begin().
  • displayLowBatteryWarning() — low-battery full-screen message.

Constants: DISPLAY_WIDTH = 144, DISPLAY_HEIGHT = 168; DISPLAY_BLACK, DISPLAY_WHITE, DISPLAY_INVERSE, DISPLAY_NORMAL.

See FED4_Display.cpp, FED4.h. Adafruit Sharp Memory Display, Adafruit_GFX.

Clone this wiki locally