Skip to content

Instantly share code, notes, and snippets.

View dilshan's full-sized avatar
🕌
Building castles...

Dilshan R Jayakody dilshan

🕌
Building castles...
View GitHub Profile
@dilshan
dilshan / 3d-cube-console.rs
Created January 29, 2025 15:01
Rotating cube in terminal
use std::f64::consts::PI;
use std::thread::sleep;
use std::time::Duration;
// Constants defining the dimensions of the terminal.
const TERMINAL_WIDTH: usize = 48; // Width of the terminal screen.
const TERMINAL_HEIGHT: usize = 16; // Height of the terminal screen.
/// Draws a line between two points using Bresenham's line algorithm.
///
@dilshan
dilshan / lm386-amp.dpl
Created January 8, 2025 07:04
LM386 gain simulations
<Qucs Schematic 24.4.1>
<Properties>
<View=-304,40,840,747,0.895332,0,0>
<Grid=10,10,0>
<DataSet=lm386-amp.dat>
<DataDisplay=lm386-amp.sch>
<OpenDisplay=0>
<Script=lm386-amp.m>
<RunScript=0>
<showFrame=0>
@dilshan
dilshan / hx711-module-test.c
Created November 27, 2024 16:20
STM32F405 firmware to test modified HX711 modules.
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : hx711-module-test.c
* @brief : Firmware to test modified HX711 modules with load-cells.
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
@dilshan
dilshan / wfm_receiver.grc
Last active June 1, 2021 13:25
GNURadio model for FM stereo radio receiver (88.1MHz to 107.9 MHz) using QT GUI widgets.
options:
parameters:
author: Dilshan R Jayakody
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
copyright: ''
description: ''
gen_cmake: 'On'
gen_linking: dynamic
@dilshan
dilshan / usim-demo-main.c
Created July 5, 2020 00:45
XC8 source code to test on μSim simulator (with Arduino Uno).
#include <xc.h>
#include <stdint.h>
// This is not an accurate frequency. The exact value may depend on the
// specifications of the hosting platform.
#define _XTAL_FREQ 25000
void main(void)
{
uint8_t position = 2;
@dilshan
dilshan / pt8211-dac.ino
Last active June 27, 2024 16:07
PT8211 DAC verification script for Arduino
#include <limits.h>
#ifndef PIN_BCK
#define PIN_BCK 22
#endif
#ifndef PIN_WS
#define PIN_WS 23
#endif
@dilshan
dilshan / usb-external-display-direct-mode.py
Created June 30, 2019 04:46
USB external display direct mode acess
import serial
device = serial.Serial('/dev/ttyACM0')
if device.is_open:
device.write(13)
device.write(str.encode('-360'))
device.close()
@dilshan
dilshan / usb-external-display-low-level.py
Last active June 30, 2019 03:57
USB external display module low level API call
import serial
device = serial.Serial('/dev/ttyACM0')
if device.is_open:
device.write([94, 49, 54, 49, 55, 52, 0, 0, 0, 0, 0, 0])
device.close()
@dilshan
dilshan / dtmf-sample.c
Created May 9, 2019 06:15
Arduino DTMF sample
#include "dtmfgen.h"
DTMFGenerator dtmf;
void setup()
{
}
void loop()