Skip to content

Instantly share code, notes, and snippets.

@IraAngeles
IraAngeles / raspberry-tft-9.95-ili9488.md
Created July 16, 2023 07:51 — forked from actuino/raspberry-tft-9.95-ili9488.md
Cheap 3.95 TFT Screen with ili9488 from mcufriend on a Raspberry Pi Zero
@IraAngeles
IraAngeles / template.yaml
Created July 24, 2022 04:13 — forked from ymedlop/template.yaml
Node-red Openshift Template
apiVersion: v1
kind: Template
labels:
template: nodered-openshift
metadata:
labels:
author: "ymedlop"
name: "nodered-openshift"
annotations:
description: Node-red openshift template
Total 12 modules 266.03 V
* Module 1: (22.26) 3.73 3.73 3.73 3.73 3.73 3.73 V 24.2/24.1°C
* Module 2: (22.29) 3.73 3.73 3.70 3.79 3.73 3.73 V 24.3/24.0°C
* Module 3: (22.26) 3.73 3.73 3.73 3.73 3.73 3.73 V 24.0/23.9°C
* Module 4: (22.28) 3.73 3.73 3.73 3.73 3.73 3.73 V 23.9/24.0°C
* Module 5: (22.28) 3.73 3.73 3.73 3.73 3.73 3.73 V 23.8/23.7°C
* Module 6: (22.22) 3.73 3.74 3.73 3.72 3.71 3.71 V 23.8/23.7°C
* Module 7: (22.27) 3.73 3.73 3.73 3.73 3.73 3.73 V 24.0/23.9°C
* Module 8: (22.26) 3.73 3.73 3.73 3.73 3.73 3.73 V 23.8/23.8°C
* Module 9: (22.28) 3.73 3.73 3.73 3.73 3.73 3.73 V 23.9/24.0°C
void update_bms_discharge_motor_torque_req_limit()
{
// Limit torque request according to bms_status.max_discharge_current_Ax10
if(bms_status.max_discharge_current_Ax10 < 2000){
// Calculate rough motor current limit based on motor speed, rail
// voltage and rail current limit
float speed_rpm = abs(inverter_status.speed / INVERTER_BITS_PER_RPM);
float rail_voltage = inverter_status.voltage / INVERTER_BITS_PER_VOLT;
float rail_current_per_motor_current = speed_rpm / 3000.0f;
float rail_current_limit = (float)bms_status.max_discharge_current_Ax10 / 10.0f;
function createAndSendOffer(){
if(channel){
channel.close();
}
// Create Data channel
channel = connection.createDataChannel('channel', {});
setChannelEvents(channel);
// Create Offer
function connectToWebSocket(){
socket = new WebSocket(webSocketConnection);
// Create WebRTC connection only if the socket connection is successful.
socket.onopen = function(event) {
log('WebSocket Connection Open.');
createRTCPeerConnection();
};
// Handle messages recieved in socket
function createRTCPeerConnection(){
connection = new RTCPeerConnection(configuration);
// Add both video and audio tracks to the connection
for (const track of localStream.getTracks()) {
log("Sending Stream.")
existingTracks.push(connection.addTrack(track, localStream));
}
// This event handles displaying remote video and audio feed from the other peer
function createAndSendAnswer(){
// Create Answer
connection.createAnswer().then(
answer => {
log('Sent The Answer.');
// Set Answer for negotiation
connection.setLocalDescription(answer);