Skip to content

02 Configuration

lovebootcaptain edited this page Jun 30, 2020 · 2 revisions

get an api key from weatherbit.io

add API key and other options to the config file

when your Pi has rebooted

create a new config-file

cd
cd WeatherPi_TFT
cp example.config.json config.json

edit the config.json file

nano config.json

configure your display options

  "DISPLAY": {
    "WIDTH": 240,
    "HEIGHT": 320,
    "FPS": 30,
    "AA": false,
    "ANIMATION": false,
    "FRAMEBUFFER": "/dev/fb1",
    "PWM": false,
    "SHOW_FPS": true,
    "SHOW_API_STATS": true,
    "MOUSE": true
  },
  • as long as you configure a 3:4 ratio the dashboard will be scaled
  • FPS is used for pygame internal ticks - 30 fps is more than enough to render clock transitions and precipitation animations smoothly
  • AA turns antialiasing on and off (leave it on a Pi Zero off, it is performance heavy on higher FPS)
  • ANIMATION enables the little particle simulation for precipitation, disable will show an image instead
  • set FRAMEBUFFER according to your display, some use fb0 (e.g. @pimoroni HyperPixel4) some fb1 (most ili9341 from @adafruit), for local development or HDMI displays set it to false
  • set PWM to your GPIO pin if your display support pwm brightness (HyperPixel supports GPIO 19 for pwm brightness) - may need some code adjustments on your side depending on your display (some are bright enough with pwm 25, some ore not) otherwise set it to false
  • SHOW_FPS show the current fps on the display
  • SHOW_API_STATS show how many API calls are left over (resets every midnight UTC)
  • MOUSE enable/disable mouse pointer - needed for local development, better leave it disabled

configure weatherbit.io settings

  • replace xxxxxxxxxxxxxxxxxxxxxxxxx in "WEATHERBIT_IO_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxx" with your own API key
  • replace en in "WEATHERBIT_LANGUAGE": "en" with your preferred language
  • replace de in "WEATHERBIT_COUNTRY": "de" with your country
  • replace 10178 in "WEATHERBIT_POSTALCODE": 10178 with your zip code / postal code (this example-location zip code is from berlin city, germany)
  • for language-support, units, etc please refer to -> weatherbit API Docs

localise hardcoded strings and ISO settings

  "LOCALE": {
    "ISO": "en_GB",
    "RAIN_STR": "Rain",
    "SNOW_STR": "Snow",
    "PRECIP_STR": "Precipitation",
    "METRIC": true
  },
  • change "ISO" and "METRIC" according to your needs
  • "METRIC": true will get all weather data units as metric system, change to false if you prefer imperial styled units
    • °C will be °F and km/h will be `mph
    • will also change the request parameter untis for the api request (see weatherbit API Docs for more details)

timer options

  "TIMER": {
    "UPDATE": 420,
    "RELOAD": 30
  },
  • the UPDATE timer defines how often the API will be called in seconds - 7min will give you enough API calls over the day
  • RELOAD defines who often the information on the display will be updated

theme file and theme options

set your theme file [darcula.theme, light.theme or example.theme] in config.json

"THEME": "darcula.theme",
  • inside your THEME you can specify with json file with theming information -> an example for the default theme is in the file example.theme.json
  • you must also try the new darcula.theme.json which is an homage to jetBrains great darcula theme for their IDE's -> see screenshots below
    • you can change some basic theme information
    • change colors of status bar icons and the wind direction icon with the theme colors
      "RED" is used for errors in status bar icons and wind direction
      "BLUE" is used for sync and update in status bar icons and rain precip icon
      "GREEN" is used for everything fine in status bar icons
      
    • change every color of an image by adding a color (r, g, b) to the optional fillcolor parameter in the DrawImage class
    • change the time and date format according to your preferences
      • a good reference for strftime options can be found here Python strftime()
      • for 12h clock with am and pm support you can use "%I:%M:%S %p" instead of "%H:%M:%S" for a 24h clock in yourTheme.DATE_FORMAT.TIME
      • for imperial like date format just change "%A - %d. %b %Y" to "%A - %b %d %Y" in yourTheme.DATE_FORMAT.DATE
    • or create your own theme with your fonts and add it to your config/theme`