syntax highlighting based on Pygments' default colors

page rendered by gronk

rss feed

List of posts

Press (Shift+)Enter to open first result (in new tab)

alvi’s blog

blog!

not using my phone until i don’t want to

4 hours a day is a quarter of your waking life!

for a long while now i’ve been trying to bring my screen time to under 7 hours a week, doing the usual business of making my phone greyscale to make it less interesting and disabling tap/raise to wake to increase friction.

last week i achieved that goal by physically distancing myself from my phone, including not taking it with me at all when i went to the gym, and i averaged 56 minutes per day.

these are some disparate notes on the process.

week 1: 7 hours a week

this week involved driving home from uni, a 4 hour drive. usually this would involve putting up maps on my phone but as i’ve done the drive a few times now i figured it would be fine, but a big part of me still wanted the comfort i was used to.

it did involve getting lost though. i wanted to use my ipod for music on this drive so before leaving for home i drove to the shops to pick up a 3.5 mm cable. i didn’t know how to get to the main roads from the shop i got the cable from and didn’t bother to look it up so i ended up going the wrong way. after 5-10 minutes of being confused, realising i went the wrong way, wondering how i knew so little about a town i’ve lived in 4 years, trying to backtrack, and failing to backtrack i found a road i knew would take me to the motorway.

doggie ipod

weeks 2 and 3: 1 hour a week?, and planning

week 2 screen time: 34, 1061, 12, 10, 6, 19, 7 (i decided i would try to get under 1 hour a week tuesday night)

week 3 screen time: i thought it was 1h32, with no days over 30 minutes, but i now think this information is wrong and the true data is lost forever

in week 1, and afterwards, i found myself reaching for my phone when it wasn’t there during quiet moments or boredom which makes me think there is still work to be done. i still need a phone for things like two factor authentication and online banking but i think it would be interesting to see if i can eliminate using my phone outside of essential utilities (and ideally move as many of those off my phone as is reasonable). the numbers really are arbitrary but my goal is under 1 hour per week, or 514 seconds per day.

while trying to get under an hour a day in week 1, i almost missed an important event because i hadn’t checked my phone calendar (sufferring from success). my todo list has been pen and paper for years now but if i’m going to reduce my screen time further my calendar too must go analogue. this month isn’t very busy for me so i can’t really speak to how well it works but i do quite like the way it looks.

very empty calendar. makes it easy to try but perhaps not representative. i think the thick line to split the weekend was a genius move from me but i probably got the idea from somewhere i can’t remember.

at first it felt difficult to wait for things to happen without a bit of scrolling but by week 3 i started finding it easier to wait without doing anything. it was still definitely a conscious decision to not get out my phone but the decision not to is getting quicker and easier.

navigation is one of the big things i feel like i need my phone for but maybe that’s not true? i’ve driven to a some new places these few weeks and it was generally fine as long as i had a bit of preparation.

london

in the 7 hours week i drove a route i’d driven before between two places i’d lived in for a long time and still got lost. i definitely take maps on my phone for granted and it’s one of the genuinely useful tools on a phone but my silly rules are my silly rules and they are not exempt.

on saturday, week 2, i had to go collect a pc case i bought second-hand online in a place i’d never been to before or knew anything about. it was about 90 minutes away by car and the plan was simple: write the directions down in my notebook the night before on my computer and also try to remember them2. i used street view to get an idea of the place and view of some landmarks to place myself with, but otherwise i think i could’ve done this with a map of london.

these directions look pretty useless like this..
snug fit

brighton and devil’s dyke

on sunday, week 2, i drove to a friend’s house in brighton. i’d driven there before but with maps and i don’t really know brighton. no issues up until i was about a minute away but i didn’t know what street i was on so wandered around for 10 minutes looking for the right place. all good fun.

on monday, week 3, i drove up to devil’s dyke with a friend and forgot the way to get there, ending up miles from where we were trying to go and trying to get there by moving in what felt like the right direction. we had nowhere to be, it was a lovely day, and it was fun to find the way without a map, even if meant driving in and out of brighton a couple times.

some random garage 10 miles away

on wednesday, week 3, i dropped the ball a bit when i had to drive to a garage i’d never been to before in a car i’d never driven before. i used my phone without really thinking to plan the trip ahead instead.

my screen time that day totaled 48 minutes with 28 minutes of navigation :/


  1. i had a lapse i think i was watching youtube in bed on my phone maybe not good not good but still okay↩︎

  2. at first i didn’t write any return directions and was gonna drive around london until i saw a sign that pointed me towards the m25, but i realised that was silly↩︎

website update 2026-04-03: new recipes and website status line

going forward, website updates with changes in content will be accompanied by a blog post.

a status line was added to the home page for quick updates on the website, with status viewable at /status.

another recent addition is some new recipes have been added:

finally, /tidbits has been renamed to /shoebox but don’t worry! your /tidbits/* bookmarks have not been changed!

last.fm bookmarklets

last.fm doesn’t let you see how many scrobbled you’ve made in one day particularly easily. Here is a bookmarklet to solve that.








When you press generate bookmarklet, the values OFFSET, DAYS, USERNAME will be subsituted and put into the link above. It’s always best to inspect bookmarklets though. Inspect the page to view the script used to generate the bookmarklet.

Repurposing Racing Wheel Pedals

I have a Logitech G27 I don’t use much. I wondered if I could use it for anything else. I could.

The Pinout of the Connector

The first thing I had to do was figure out what each pin did on the DE-9 connector, and which ones I should care about. This was done easily after I took off the top plastic casing thing by poking the three 100k Ohm potentiometers and the connector in the right places at the right times:

pin function
1,4 ground
6 clutch pedal
7 brake pedal
8 accelerator pedal
9 voltage in

Reading the Values of the Pots

I’m using an Arduino to read the pots and then do something with the values. I very dirtily wired pin 4 on the pedals to GND on a Arduino Uno, pin 9 to 5V, and pins 6,7,8 to A0, A1, and A2. I used a basic sketch to check that everything is good:

Show/hide test_sketch.ino
 void setup() {
	Serial.begin(9600);
}

void loop() {
	Serial.println(analogRead(A2));
	delay(20);
}

I noticed that the minimum and maximum values read by the Uno were quite far off 0 and 1024, like they should be, and voltage was being lost on the way to and from the potentiometers. Since the pedals have to be calibrated every time you plug them in, I assume this is normal and spat out this code:

Show/hide sketch_aug02a.ino
// sensor pins
int sa = A0;
int sb = A1;
int sc = A2;

// minimum values detected by the sensors
int mina = 1025;
int minb = 1025;
int minc = 1025;

// maximum values detected by the sensors
int maxa = 512;
int maxb = 512;
int maxc = 512;

// raw values of the sensors
int rva, rvb, rvc;

// calculated values of the sensors (between 0 and 1, this is the value sent to computer)
float cva, cvb, cvc;

void setup() {
	Serial.begin(9600);
}

void loop() {
	rva = analogRead(sa);
	rvb = analogRead(sb);
	rvc = analogRead(sc);

	if (rva < mina) mina = rva;
	if (rvb < minb) minb = rvb;
	if (rvc < minc) minc = rvc;

	if (rva > maxa) maxa = rva;
	if (rvb > maxb) maxb = rvb;
	if (rvc > maxc) maxc = rvc;

	cva = (float)(rva-mina)/(float)(maxa-mina);
	cvb = (float)(rvb-minb)/(float)(maxb-minb);
	cvc = (float)(rvc-minc)/(float)(maxc-minc);

	Serial.print('[');
	Serial.print(cva); Serial.print(',');
	Serial.print(cvb); Serial.print(',');
	Serial.print(cvc);
	Serial.print(']');
	Serial.println();
	delay(20); 
}

Actually Making the Numbers Do Something

This is where you can make the pedals do fun things. I reworked another piece of code I wrote to do a similar thing to quickly create a script that reads the values sent by the Arduino, and then simulate pressing a key combination. The only thing I’ve done with this is set push-to-talk to ctrl-shift-alt-1. I don’t know what else I could use this for, maybe temporarily muting particular things, like music.

Show/hide pedalboard.py
 #!/usr/bin/env python3

import sys
import json
import time
from enum import Enum

import keyboard
import serial

class KeyState(Enum):
    UP = 0
    DOWN = 1

STATES = [KeyState.UP] * 3
THRESHOLD = 0.8
MACROS = ['ctrl+shift+alt+1', 'ctrl+shift+alt+2', 'ctrl+shift+alt+3']

def get_args():
    """ Get command line arguments """

    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('device')
    return parser.parse_args()


def main(args):
    """ Entry point for script """
    while True:
        try:
            kb = serial.Serial(port=args.device, baudrate=9600)
            while True:
                handle(json.loads(kb.readline()))
        except serial.serialutil.SerialException as e:
            print(e)
            print("Failed to connect to device... trying again")
            time.sleep(1)
        except Exception as e:
            print(e)
    return 0

def handle(data):
    global STATES

    states = [KeyState.DOWN if value > THRESHOLD else KeyState.UP for value in data]
    r = [handle_state_change(i, states[i]) if states[i] != STATES[i] else None for i in range(len(STATES))]
    STATES = states
    return r

def handle_state_change(key, newstate):
    print(f"{key} {newstate}")
    return keyboard.press(MACROS[key]) if newstate == KeyState.DOWN else keyboard.release(MACROS[key])


if __name__ == '__main__':
    try:
        sys.exit(main(get_args()))
    except KeyboardInterrupt:
        sys.exit(0)

first post

this is my first post

alvi’s blog

blog!

page rendered by gronk