Skip to content

Instantly share code, notes, and snippets.

@sonnny
sonnny / pico_cli.txt
Created January 22, 2025 04:24
pico cli demo
// https://github.com/kelu124/pic0rick/blob/main/software/rp2040_shell/main.c
// template console how to get command line from usb then process
// example: loco speed 15 4 -- set loco speed address 15 to 4
// k
#include <pico/stdio_usb.h>
#include <string.h>
#include <stdio.h>
typedef void (*command_func_t)(const char *args);
@sonnny
sonnny / touch.txt
Last active January 12, 2025 17:18
pico touch pad demo
/*
touch demo for pico rp2040
cmake_minimum_required(VERSION 3.13)
set(PICO_SDK_PATH "/home/sonny/pico/pico-sdk")
set(PICOTOOL_FETCH_FROM_GIT_PATH "/home/sonny/pico/picotool")
set(PICO_BOARD waveshare_rp2040_zero CACHE STRING "Board type")
include(/home/sonny/pico/pico-sdk/external/pico_sdk_import.cmake)
project(main C CXX ASM)
@sonnny
sonnny / flutter_picow_udp.txt
Last active October 17, 2024 16:27
flutter connects wireless with pico w using udp
demo to connect flutter to picow using udp
////////////////////main.dart
import 'package:flutter/material.dart';
import 'dart:io';
RawDatagramSocket? socket;
void main() async {
@sonnny
sonnny / pico_pca9685_demo.txt
Created March 5, 2024 21:08
pico i2c demo with pca9685
/*
*
* demo of pico using pca9685 without library
* this is for 2 rc servo
* verified with pulseview march 4, 2024
* 16 bit register content below
1490 us ------ center
on 0x0000
off 0x013B
@sonnny
sonnny / dcc_encode_decode.txt
Last active February 19, 2024 22:52
pico pio test to decode/encode nmra dcc protocol, work in progress
//////////////readme.txt
when using flutter syntax view to view
source file, don't forget to replace dollar sign
so the code text will have multiple colors
nmra dcc decoder encoder
this is my project to generate and encode nmra
dcc pulses for model train. google nmra dcc
@sonnny
sonnny / pico_gamepad_pio.txt
Created January 5, 2024 14:00
pico pio demo of issuing irq and wait until program responds, also demo of passing pointer from main to other file to update
demo of pico decoding nes gamepad
demo of pico issuing irq to main program
main program responds and clears the irq
source file from https://codeberg.org/chipfire/rppico-pio-gamepad
/****************************
* gptest.c
**************************/
@sonnny
sonnny / pico_bluetooth_gamepad.txt
Created January 5, 2024 13:50
demo of pico w bluetooth using an nes gamepad, demo of pio irq, send signal to program from pio
demo of nes gamepad using pico w bluetooth
source from https://codeberg.org/chipfire/rppico-bt-gamepad
/****************************
* bt_gamepad.c
**********************/
/**
* Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
*
@sonnny
sonnny / pico_usb_keyboard.txt
Created January 5, 2024 13:35
minimal pico usb keyboard, no matrix switches just plain switches wired to pico gpio pin, tested and works with reduced number of gpio pin for testing
simple demo of usb keyboard
no matrix keyboard, 1 key per pico gpio
source from https://github.com/PhilboBaggins/pico-keys
tested good with switches
/************************
* PicoKeysExample.c
***********************/
#include <ctype.h>
@sonnny
sonnny / flutter_syntax.txt
Created January 1, 2024 09:00
flutter demo of syntax view showing source file
import 'package:flutter/material.dart';
import 'package:flutter_syntax_view/flutter_syntax_view.dart';
import 'package:get/get.dart';
import './dark_light.dart';
void main() {
runApp(MaterialApp(home:MyApp(),
debugShowCheckedModeBanner:false));}
class MyApp extends StatelessWidget{
@sonnny
sonnny / pio_minimal.txt
Last active December 29, 2023 01:19
demo of pico pio minimal initialization done in main instead of .pio file, includes CMakeLists.txt and instruction on how to generate a pico project
//
// pio_minimal.c
// demo for minimal pio
// pio initialize is in main
// you normally see pio init in .pio file
//
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/pio.h"