Additionally Badger 2040 W does not have a "user" button since the BOOTSEL button (which originally doubled as "user") is now aboard the attached Pico W.
:warning: If you're using the examples-included firmware you're good to go, otherwise you'll need to copy `examples/badger2040w/lib/badger2040w.py`, `micropython/examples/badger2040w/WIFI_CONFIG.py`and `examples/badger2040w/lib/network_manager.py` over to your Badger 2040 W.
Since Badger 2040 W is based upon PicoGraphics you should read the [PicoGraphics function reference](../picographics/README.md) for more information about how to draw to the display.
### Pen Colour
There are 16 pen colours - or "shades of grey" - to choose, from 0 (black) to 15 (white).
Since Badger 2040 W cannot display colours other than black and white, any value from 1 to 14 will apply dithering when drawn, to simulate a shade of grey.
The white indicator LED can be controlled, with brightness ranging from 0 (off) to 255:
```python
led(
brightness # int: 0 (off) to 255 (full)
)
```
## Buttons
Badger 2040 W features five buttons on its front, labelled A, B, C, ↑ (up) and ↓ (down). These can be read using the `pressed(button)` method, which accepts the button's pin number. For convenience, each button can be referred to using these constants:
*`BUTTON_A` = `12`
*`BUTTON_B` = `13`
*`BUTTON_C` = `14`
*`BUTTON_UP` = `15`
*`BUTTON_DOWN` = `11`
Additionally you can use `pressed_any()` to see if _any_ button has been pressed.
## Waking From Sleep
### Button Presses
When running on battery, pressing a button on Badger 2040 W will power the unit on. It will automatically be latched on and `main.py` will be executed.
There are some useful functions to determine if Badger 2040 W has been woken by a button, and figure out which one:
*`badger2040w.woken_by_button()` - determine if any button was pressed during power-on.
*`badger2040w.pressed_to_wake(button)` - determine if the given button was pressed during power-on.
*`badger2040w.reset_pressed_to_wake()` - clear the wakeup GPIO state.
*`badger2040w.pressed_to_wake_get_once(button)` - returns `True` if the given button was pressed to wake Badger, and then clears the state of that pin.
### Real-time Clock
Badger 2040 W includes a PCF85063a RTC which continues to run from battery when the Badger is off. It can be used to wake the Badger on a schedule.
## Update Speed
The E Ink display on Badger 2040 W supports several update speeds. These can be set using `set_update_speed(speed)` where `speed` is a value from `0` to `3`. For convenience these speeds have been given the following constants:
*`UPDATE_NORMAL` = `0`
*`UPDATE_MEDIUM` = `1`
*`UPDATE_FAST` = `2`
*`UPDATE_TURBO` = `3`
## System speed
The system clock speed of the RP2040 can be controlled, allowing power to be saved if on battery, or faster computations to be performed. Use `badger2040w.system_speed(speed)` where `speed` is one of the following constants:
*`SYSTEM_VERY_SLOW` = `0`_4 MHz if on battery, 48 MHz if connected to USB_
*`SYSTEM_SLOW` = `1`_12 MHz if on battery, 48 MHz if connected to USB_
*`SYSTEM_NORMAL` = `2`_48 MHz_
*`SYSTEM_FAST` = `3`_133 MHz_
*`SYSTEM_TURBO` = `4`_250 MHz_
On USB, the system will not run slower than 48MHz, as that is the minimum clock speed required to keep the USB connection stable.
It is best to set the clock speed as the first thing in your program, and you must not change it after initializing any drivers for any I2C hardware connected to the Qwiic port. To allow you to set the speed at the top of your program, this method is on the `badger2040w` module, rather than the `badger` instance, although we have made sure that it is safe to call it after creating a `badger` instance.
Note that `SYSTEM_TURBO` overclocks the RP2040 to 250MHz, and applies a small over voltage to ensure this is stable. We've found that every RP2040 we've tested is happy to run at this speed without any issues.