Hirdetés
- Fotók, videók mobillal
- Minden a BlackBerry telefonokról és rendszerről
- Félő, hogy az okosszemüveg a szexuális zaklatók játékszere lesz
- Honor Magic8 Pro - bevált recept kölcsönvett hozzávalókkal
- Vivo X300 Ultra - tárcsázz, ha van rá keret!
- Honor Magic 8 Pro Air a neve, január 19-én mutatják be
- Xiaomi 17 Ultra - jó az optikája
- Óra vagy karperec? Egészségügyi mindenes!
- Google Pixel 9 Pro XL - hét szűk esztendő
- Poco X8 Pro Max - nem kell ide sem bank, sem akkubank
-
Mobilarena
Amit érdemes tudni a Raspberry Pi-kről:
A legelső változat 2012-ben jelent meg. Pici, olcsó és nagyon alacsony fogyasztású, hobby-célú kártyagép. Felépítése ARM alapú, nem PC-architektúra, hanem kb. egy régi mobilhoz hasonló. Nagyon sok mindenre használható! A Linux-nak és a magas eladási mennyiségnek köszönhetően jelentős fejlesztőtáborral rendelkezik.
Új hozzászólás Aktív témák
-
Szita1
tag
/*
* RemoteSwitch library v2.3.0 (20121229) made by Randy Simons http://randysimons.nl/
* See RemoteReceiver.h for details.
*
* License: GPLv3. See license.txt
*/
#include "RemoteReceiver.h"
/************
* RemoteReceiver
************/
int8_t RemoteReceiver::_interrupt;
volatile int8_t RemoteReceiver::_state;
byte RemoteReceiver::_minRepeats;
RemoteReceiverCallBack RemoteReceiver::_callback;
boolean RemoteReceiver::_inCallback = false;
boolean RemoteReceiver::_enabled = false;
void RemoteReceiver::init(int8_t interrupt, byte minRepeats, RemoteReceiverCallBack callback) {
_interrupt = interrupt;
_minRepeats = minRepeats;
_callback = callback;
enable();
if (_interrupt >= 0) {
attachInterrupt(_interrupt, interruptHandler, CHANGE);
}
}
void RemoteReceiver::enable() {
_state = -1;
_enabled = true;
}
void RemoteReceiver::disable() {
_enabled = false;
}
void RemoteReceiver::deinit() {
_enabled = false;
if (_interrupt >= 0) {
detachInterrupt(_interrupt);
}
}
void RemoteReceiver::interruptHandler() {
if (!_enabled) {
return;
}
static unsigned int period; // Calculated duration of 1 period
static byte receivedBit; // Contains "bit" currently receiving
static unsigned long receivedCode; // Contains received code
static unsigned long previousCode; // Contains previous received code
static byte repeats = 0; // The number of times the an identical code is received in a row.
static unsigned long edgeTimeStamp[3] = {0, }; // Timestamp of edges
static unsigned int min1Period, max1Period, min3Period, max3Period;
static bool skip;
// Filter out too short pulses. This method works as a low pass filter.
edgeTimeStamp[1] = edgeTimeStamp[2];
edgeTimeStamp[2] = micros();
if (skip) {
skip = false;
return;
}
if (_state >= 0 && edgeTimeStamp[2]-edgeTimeStamp[1] < min1Period) {
// Last edge was too short.
// Skip this edge, and the next too.
skip = true;
return;
}
unsigned int duration = edgeTimeStamp[1] - edgeTimeStamp[0];
edgeTimeStamp[0] = edgeTimeStamp[1];
// Note that if state>=0, duration is always >= 1 period.
if (_state==-1) { // Waiting for sync-signal
if (duration>3720) { // =31*120 minimal time between two edges before decoding starts.
// Sync signal received.. Preparing for decoding
period=duration/31;
receivedCode=previousCode=repeats=0;
// Allow for large error-margin. ElCheapo-hardware :(
min1Period=period*4/10; // Avoid floating point math; saves memory.
max1Period=period*16/10;
min3Period=period*23/10;
max3Period=period*37/10;
}
else {
return;
}
} else if (_state<48) { // Decoding message
receivedBit <<= 1;
// bit part durations can ONLY be 1 or 3 periods.
if (duration<=max1Period) {
receivedBit &= B1110; // Clear LSB of receivedBit
}
else if (duration>=min3Period && duration<=max3Period) {
receivedBit |= B1; // Set LSB of receivedBit
}
else { // Otherwise the entire sequence is invalid
_state=-1;
return;
}
if ((_state%4)==3) { // Last bit part?
// Shift
receivedCode*=3;
// Only 4 LSB's are used; trim the rest.
switch (receivedBit & B1111) {
case B0101: // short long short long == B0101
// bit "0" received
receivedCode+=0; // I hope the optimizer handles this ;)
break;
case B1010: // long short long short == B1010
// bit "1" received
receivedCode+=1;
break;
case B0110: // short long long short
// bit "f" received
receivedCode+=2;
break;
default:
// Bit was rubbish. Abort.
_state=-1;
return;
}
}
} else if (_state==48) { // Waiting for sync bit part 1
// Must be 1 period.
if (duration>max1Period) {
_state=-1;
return;
}
} else { // Waiting for sync bit part 2
// Must be 31 periods.
if (duration<period*25 || duration>period*36) {
_state=-1;
return;
}
// receivedCode is a valid code!
if (receivedCode!=previousCode) {
repeats=0;
previousCode=receivedCode;
}
repeats++;
if (repeats>=_minRepeats) {
if (!_inCallback) {
_inCallback = true;
(_callback)(receivedCode, period);
_inCallback = false;
}
// Reset after callback.
_state=-1;
return;
}
// Reset for next round
receivedCode = 0;
_state=0; // no need to wait for another sync-bit!
return;
}
_state++;
return;
}
boolean RemoteReceiver::isReceiving(int waitMillis) {
unsigned long startTime=millis();
int waited; // Signed int!
do {
if (_state == 48) { // Abort if a valid code has been received in the mean time
return true;
}
waited = (millis()-startTime);
} while(waited>=0 && waited <= waitMillis); // Yes, clock wraps every 50 days. And then you'd have to wait for a looooong time.
return false;
}
Új hozzászólás Aktív témák
- Budapest és környéke adok-veszek-beszélgetek
- Hálózati / IP kamera
- Házimozi belépő szinten
- Fotók, videók mobillal
- Kodi és kiegészítői magyar nyelvű online tartalmakhoz (Linux, Windows)
- Xbox tulajok OFF topicja
- Valami baja van a tápomnak
- Víz- gáz- és fűtésszerelés
- Minden a BlackBerry telefonokról és rendszerről
- Telekom otthoni szolgáltatások (TV, internet, telefon)
- További aktív témák...
- 2K Gamer PC - Ryzen 7 5700X / RX 7700 XT 12GB / B550M WIFI / 32GB RAM / 1TB NVMe SSD / 650W GOLD
- NAS config elado
- RYZEN 5 9600x - XFX RX 9060XT 16GB - 2x16GB DDR5 6000MHz CL32(A-Die) - 1,25TB SSD - NZXT KRAKEN
- i5-9400F / 16GB DDR4 / RX480 8GB / 240GB SSD + 500GB HDD
- GAMER PC : RYZEN 9 9950X3D /// 64 GB DDR5 6400MHZ CL32 /// ROG ASTRAL RTX5090 32 GB /// 1+2 TB SSD
- Kezdő Gamer PC-Számítógép! Csere-Beszámítás! I5 7500 / GTX 1650 / 16GB DDR4 / 128SSD + 500HDD
- MSI GF65 Thin - 15,6"FHD 120Hz IPS - i5-9300H - 16GB - 1,25TB SSD - Win11 - GTX 1660 Ti - MAGYAR
- Asus TUF A15 FX506 - 15.6" Full HD 144Hz - Ryzen 5-4600H - 8GB - 512GB - Win11 - GTX 1650 Ti - HUN
- Xiaomi 15 256GB,Újszerű,Dobozaval,12 hónap garanciával
- Honor X7b / 6/128GB / Kártyafüggetlen / 12Hó Garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
wassermann
