reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit 2f9c1b1354bc5b1f33a002e86e69920802473572
parent 266f2a7fbe19d384760fcafade4c78d20c1ce997
Author: Lukas F. Hartmann <lukas@mnt.mn>
Date:   Fri, 23 Nov 2018 19:38:38 +0100

Merge branch 'master' of https://github.com/mntmn/reform

Diffstat:
Ahandbook/build-pdf.sh | 5+++++
Ahandbook/reform-handbook-cover.pdf | 0
Mhandbook/reform-handbook.pdf | 0
Mhandbook/source/credits/index.rst | 2+-
Mhandbook/source/motherboard/attiny.rst | 7++++---
Areformd/i3status.conf | 29+++++++++++++++++++++++++++++
Areformd/install-systemd.sh | 32++++++++++++++++++++++++++++++++
Areformd/reformd.service | 12++++++++++++
Mreformd/reformd.sh | 19+++++++++----------
Areformd/screenshot.png | 0
Areformd/status-bar.sh | 18++++++++++++++++++
11 files changed, 110 insertions(+), 14 deletions(-)

diff --git a/handbook/build-pdf.sh b/handbook/build-pdf.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -xe +make latexpdf +pdftk A=reform-handbook-cover.pdf B=build/latex/Reform.pdf cat A1 B2-end output reform-handbook.pdf + diff --git a/handbook/reform-handbook-cover.pdf b/handbook/reform-handbook-cover.pdf Binary files differ. diff --git a/handbook/reform-handbook.pdf b/handbook/reform-handbook.pdf Binary files differ. diff --git a/handbook/source/credits/index.rst b/handbook/source/credits/index.rst @@ -7,7 +7,7 @@ Credits :Sleeve Design, Assembly: Greta Melnik -:Special Thanks: FabLab Berlin, Neuform, CCC Berlin/n-te, Fedevel/Voipac, etnaviv, Xorg, Mesa, wayland, Igalia, heise/Make Germany/Helga Hansen, Philip Steffan, Maker Faire Berlin, Interface Critique/Florian Hadler, Gabriel Yoran, JD Music Labs, Crowd Supply, malcolmputer, zakx, darthrake, erlehmann, plomlompom, scallo, dridde, grncdr, oomono, Novena, Mastodon, a1k, Disko Koenig, S.I.H., The Reform Beta Testers (you!), Chris Healy, Martin Borgert, Gregor May, Stephan Urbach +:Special Thanks: FabLab Berlin, Neuform, CCC Berlin/n-te, Fedevel/Voipac, etnaviv, Xorg, Mesa, wayland, Igalia, heise/Make Germany/Helga Hansen, Philip Steffan, Maker Faire Berlin, Interface Critique/Florian Hadler, Gabriel Yoran, JD Music Labs, Crowd Supply, malcolmputer, zakx, darthrake, erlehmann, plomlompom, scallo, dridde, grncdr, oomono, Daniel Stone, Martin Meyerhoff, Gregor May, Chris Healy, Martin Borgert, Stephan Urbach, furan, Novena, Mastodon, a1k, Disko Koenig, S.I.H., The Reform Beta Testers (you!) :Inter UI Font: rsms diff --git a/handbook/source/motherboard/attiny.rst b/handbook/source/motherboard/attiny.rst @@ -32,9 +32,10 @@ It accepts commands in the form of a single letter followed by return. The curre In addition, these commands can be prefixed with a decimal number (up to four digits): -- *600b*: Reset the battery capacity counter to 10Ah (600 Amp minutes) +- *600c: Reset the battery capacity counter to 10Ah (600 Amp minutes) - *500t*: Set the lid sensor open/closed threshold to the value 500 - +- *10w*: Set the lid sensor open/closed hysteresis to 10 + Undervoltage Protection (UVLO) ------------------------------ @@ -43,7 +44,7 @@ The microcontroller is supposed to detect a dangerously low voltage on the batte Lid Sensor ---------- -The ATTiny senses if the lid is open or closed using the hall effect sensor (Honeywell SS495A). The lid is considered closed when a magnet is close to the sensor. The ATTiny outputs the string "lid_open" via its serial port which can wake the i.MX6 up from sleep. +The ATTiny senses if the lid is open or closed using the hall effect sensor (Honeywell SS495A). The lid is considered closed when a magnet is close to the sensor. The ATTiny outputs the string "wake" via its serial port which can wake the i.MX6 up from sleep. Flashing the Firmware --------------------- diff --git a/reformd/i3status.conf b/reformd/i3status.conf @@ -0,0 +1,29 @@ +# + +general { + interval = 1 + colors = true + color_good = '#88b090' + color_degraded = '#ccdc90' + color_bad = '#e89393' +} + + +order += "cpu_usage" +order += "wireless wlp1s0" +order += "external_script" + +cpu_usage { + format = "CPU %usage" +} + +wireless wlp1s0 { + format_up = "WIFI %quality %essid %ip" + format_down = "" +} + +external_script { + format = " {output}" + script_path = "/bin/sh /etc/reform/status-bar.sh" +} + diff --git a/reformd/install-systemd.sh b/reformd/install-systemd.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -x + +mkdir -p /etc/reform +cp reformd.sh /etc/reform/ +cp status-bar.sh /etc/reform/ +cp reformd.service /etc/systemd/system/ +systemctl daemon-reload +systemctl enable reformd.service +systemctl start reformd.service + +cat << EOF + +To integrate reformd into i3bar, do the following steps: + +- Install py3status (sudo apt install py3status) +- Adapt your i3 config to use py3status and /etc/reform/status-bar.sh: + +bar { + status_command py3status -c ~/.config/i3status.conf +} + +- Copy the i3status.conf from this directory to ~/.config/i3status.conf +- Take a look at that file and adapt to your needs +- Reload i3 (normally Mod+Shift+R) + +To follow reformd status output, use: +- journalctl -fu reformd.service + +EOF + diff --git a/reformd/reformd.service b/reformd/reformd.service @@ -0,0 +1,12 @@ +[Unit] +Description=Reform Battery, Fan, Lid Controller + +[Service] +Type=simple +ExecStart=/etc/reform/reformd.sh +Restart=always +User=root + +[Install] +WantedBy=multi-user.target + diff --git a/reformd/reformd.sh b/reformd/reformd.sh @@ -57,7 +57,7 @@ function reset_bat_capacity { setup_serial exec 99<>/dev/ttymxc1 :<&99 - printf "0600b\r" >&99 + printf "0600c\r" >&99 exec 99>&- } @@ -71,7 +71,7 @@ function system_suspend { set +e; timeout 1 head /dev/ttymxc1; set -e # zzZzzZ - systemctl suspend + echo -n mem > /sys/power/state } function regulate_fan { @@ -102,12 +102,12 @@ function main { # so it can be graphed and we can estimate remaining running time # TODO actually append to log and rotate it out # TODO interval? - timestamp=$(date +%Y-%m-%dT%H:%M:%S) + timestamp=$(date +%s) get_soc_temperature get_battery_state get_lid_state - if [ "$bat_amps" == "0.00A" ] + if [ "$bat_amps" == "0.00" ] then reset_bat_capacity fi @@ -119,14 +119,13 @@ function main { # important: this works only if the kernel option no_console_suspend=1 is set! # also, requires kernel patch when using PCIe cards: https://github.com/sakaki-/novena-kernel-patches/blob/master/0017-pci-fix-suspend-on-i.MX6.patch # (workaround for erratum "PCIe does not support L2 Power Down") - if [ "$lid_state" ] && [ "$lid_state" -eq "1" ] - then - system_suspend - exit - fi + #if [ "$lid_state" ] && [ "$lid_state" -eq "1" ] + #then + # system_suspend + # exit + #fi } -brightnessctl s 5 disable_echo while true; do diff --git a/reformd/screenshot.png b/reformd/screenshot.png Binary files differ. diff --git a/reformd/status-bar.sh b/reformd/status-bar.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +read -r temp < /sys/class/thermal/thermal_zone0/temp +temp=$((temp / 1000)) +#headphone=$(amixer get 'Headphone' | grep "Left: Playback" | cut -f 7 -d ' ') + +IFS=$',\r' +read -r x y bat_capacity bat_volts bat_amps a b </var/log/reformd + +bat_capacity=$(echo $bat_capacity | tr -d Ah) +bat_amps=$(echo "-($bat_amps)" | tr -d A | bc) + +bat_percent=$(echo "scale=2;$bat_capacity/10.0*100" | bc) + +#bat_hours=$(echo "scale=1;($bat_capacity-1.0)/$bat_amps" | bc) + +echo -n "BAT $bat_percent% (${bat_amps}A ${bat_volts}V) $tempĀ°C" +