Skip to content

Instantly share code, notes, and snippets.

@andreban
andreban / st7789.cpp
Last active December 16, 2021 14:37
An ST7789 driver for the Raspberry Pi Pico that works for screens that have the CS channel and those that don't.
#include "pico/stdlib.h"
#include "st7789.h"
St7789::St7789(
uint8_t width,
uint8_t height,
uint16_t *frame_buffer,
spi_inst *spi,
int8_t pin_dc,
int8_t pin_reset,
/*
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#include <WebUSB.h>
WebUSB WebUSBSerial(1 /* https:// */, "rotavo-pwa.firebaseapp.com");
#define Serial WebUSBSerial
// These constants won't change. They're used to give names to the pins used:
const int analogInPinA = A0; // Analog input pin that the potentiometer is attached to
const int analogInPinB = A2; // Analog input pin that the potentiometer is attached to
/*
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.test.hellowebviewjava;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@andreban
andreban / LauncherActivity.java
Created February 10, 2019 12:07
Changing Status Bar colour when launching a TWA
// Copy LauncherActivity from the support library repo
// (https://github.com/GoogleChrome/custom-tabs-client/blob/master/customtabs/src/android/support/customtabs/trusted/LauncherActivity.java#L153-L155)
// and replace the getCustomTabsIntent method, as below:
protected CustomTabsIntent getCustomTabsIntent(CustomTabsSession session) {
return new CustomTabsIntent.Builder(session)
.setToolbarColor(Color.parseColor("#000000"))
.build();
}
Bundle headers = new Bundle();
headers.putString("key", "value");
customTabsIntent.intent.putExtra(Browser.EXTRA_HEADERS, headers);
@andreban
andreban / runtimeVersionV0.js
Created July 4, 2018 12:23
Retrieves RuntimeVersion from v0.js
/**
* Copyright 2017 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@andreban
andreban / Shader.java
Last active February 24, 2018 16:11
Compile a Vertex Shared
int vertexShader = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
GL20.glShaderSource(vertexShader, vertexShaderSource);
GL20.glCompileShader(vertexShader);
String vertexShaderErrorLog = GL20.glGetShaderInfoLog(vertexShader, 65536);
if (vertexShaderErrorLog.length() != 0) {
System.err.println(
"Vertex shader compile log: \n" + vertexShaderErrorLog);
}