Wednesday, 16 February 2022

M5StickC (RF) Remote Control decoder

When tinkering with 433 Mhz RF appliance switches it's handy to easily check what codes they respond to. This is a simple decoder using the RCswitch library

 
#include <M5StickC.h>
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

int x=0;
int y=4; 
void setup() {
   M5.begin();
   M5.Lcd.setRotation(3);
   Serial.begin(115200); 
   mySwitch.enableReceive(0); 
    //labelled G0 on the "HAT" end of the M5StickC 
}

void loop() {
  if (mySwitch.available()) {
   
    Serial.print("Code ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.println(mySwitch.getReceivedProtocol() );
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(",");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print(",");
    Serial.println( mySwitch.getReceivedProtocol() );
 
    M5.Lcd.fillScreen(TFT_BLACK);
    M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);   
    M5.Lcd.setCursor(x, y, 2);
    M5.Lcd.setTextSize(1);
    M5.Lcd.print("Code ");
    M5.Lcd.print( String(mySwitch.getReceivedValue()) );
    M5.Lcd.print(" / ");
    M5.Lcd.print( String(mySwitch.getReceivedBitlength()) );
    M5.Lcd.println("bit ");
    M5.Lcd.print("Protocol: ");
    M5.Lcd.println( String(mySwitch.getReceivedProtocol()) );
    mySwitch.resetAvailable();
     
   } //if mySwitch
}//loop 
 

 

Tuesday, 1 February 2022

Internet Time (in C this time)

The plain C version: 

 
#include <stdio.h>
#include <time.h>
#include <math.h>

Monday, 31 January 2022

Internet Time (Processing)

In the glorious utopian (comparatively) early internet Swatch thought a universal time system would be a good idea. Wikipedia has an article on it : Swatch Internet Time .

Here is a "@beats" clock in Processing :

import java.util.*;  
int oldbeats=0;   	
Date trialTime;
TimeZone cet;
Calendar calendar ;

void setup() {
  size(120, 120);  
  cet=TimeZone.getTimeZone("Europe/Stockholm");
  calendar = new GregorianCalendar(cet);
}

void draw(){
 
  trialTime = new Date();
  calendar.setTime(trialTime);
  
  int beats =  floor( (calendar.get(Calendar.SECOND) + 
                      (calendar.get(Calendar.MINUTE) * 60) + 
                      (calendar.get(Calendar.HOUR_OF_DAY)  * 3600))
                      / 86.4005529635 );

  if (beats > oldbeats) { 
    oldbeats = beats;
    background(255);
    textSize(40);
    fill(0, 102, 153, 204);
    text("@"+beats, 3, 60); 
  }
  delay(1000); 
}

void mousePressed (){
  exit();
}

Monday, 10 January 2022

nginx http - https proxy

nginx configuration file in /etc/nginx/sites-enabled/

server {
  listen 81;

  location / {
    resolver 8.8.8.8;
    proxy_http_version 1.1;
    proxy_pass https://$host$request_uri;
  }
}

 

from here : https://retrocomputing.stackexchange.com/questions/17680/how-can-i-visit-https-websites-in-old-web-browsers


Thursday, 3 June 2021

World Bicycle Day 2021


 A nice day for a ride to the Lighthouse for World Bicycle Day



This southern yellow-tailed black cockatoo was merrily destructing pine cones by the foreshore.