Skip to content

Commit

Permalink
add project files for visual studio
Browse files Browse the repository at this point in the history
split up source code into individual files
  • Loading branch information
vladtepesch committed Feb 6, 2020
1 parent 81300c7 commit 4c17f5c
Show file tree
Hide file tree
Showing 21 changed files with 4,611 additions and 3,491 deletions.
9 changes: 9 additions & 0 deletions build_gcc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setlocal
SET outDir=./gccOut
mkdir %outDir%

gcc --static -Wall -DF_INTERRUPTS=10000 irmp-main-analyze.c -o %outDir%/irmp-10kHz.exe
gcc -Wall -DF_INTERRUPTS=11718 irmp-main-analyze.c -o %outDir%/irmp-11718Hz
gcc -Wall -DF_INTERRUPTS=15000 irmp-main-analyze.c -o %outDir%/irmp-15kHz
gcc -Wall -DF_INTERRUPTS=20000 irmp-main-analyze.c -o %outDir%/irmp-20kHz

47 changes: 21 additions & 26 deletions irmp-main-SharedLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
* (at your option) any later version.
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/


#include "irmp.h"
#include "irmp.c"


#ifndef IRMP_DLLEXPORT

#if defined WIN32 && defined _MSC_VER
Expand All @@ -24,17 +27,16 @@

#include "irmp-main-SharedLib.h"



static uint32_t s_endSample = 0;

uint32_t
IRMP_GetSampleRate(void)
{
uint32_t IRMP_GetSampleRate(void) {
return F_INTERRUPTS;
}

void
IRMP_Reset(void)
{

void IRMP_Reset(void) {
IRMP_PIN = 0xff;
IRMP_DATA data;
int i;
Expand All @@ -49,9 +51,8 @@ IRMP_Reset(void)
s_endSample = 0;
}

uint32_t
IRMP_AddSample(const uint8_t i_sample)
{

uint32_t IRMP_AddSample(const uint8_t i_sample) {
IRMP_PIN = i_sample;
uint_fast8_t r = irmp_ISR();
if (r) {
Expand All @@ -62,9 +63,8 @@ IRMP_AddSample(const uint8_t i_sample)
return 0;
}

uint32_t
IRMP_GetData(IRMP_DataExt* o_data)
{

uint32_t IRMP_GetData(IRMP_DataExt* o_data) {

IRMP_DATA d;
if (irmp_get_data(&d))
Expand All @@ -81,30 +81,25 @@ IRMP_GetData(IRMP_DataExt* o_data)
return FALSE;
}

IRMP_DataExt
IRMP_Detect(const uint8_t* i_buff, uint32_t i_len)
{

IRMP_DataExt IRMP_Detect(const uint8_t* i_buff, uint32_t i_len) {
IRMP_DataExt ret = { 0 };
while (s_curSample < i_len)
{
if (IRMP_AddSample(i_buff[s_curSample]))
{
while (s_curSample < i_len) {
if (IRMP_AddSample(i_buff[s_curSample])) {
IRMP_GetData(&ret);
return ret;
}
}
return ret;
}

const char *
IRMP_GetProtocolName(uint32_t i_protocol)
{
if (i_protocol < IRMP_N_PROTOCOLS)
{

const char* IRMP_GetProtocolName(uint32_t i_protocol) {
if (i_protocol < IRMP_N_PROTOCOLS) {
return irmp_protocol_names[i_protocol];
}
else
{
else {
return "unknown";
}
}

91 changes: 91 additions & 0 deletions irmp-main-SharedLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------------------------------------------------------------------------------
* irmpharedLib.h
*
* Copyright (c) 2009-2019 Frank Meyer - frank(at)fli4l.de
* Copyright (c) 2009-2019 René Staffen - r.staffen(at)gmx.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/

#ifndef IRMP_SHARED_H
#define IRMP_SHARED_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef IRMP_DLLEXPORT

#if defined WIN32 && defined _MSC_VER
# define IRMP_DLLEXPORT __declspec(dllimport)
#else
# define IRMP_DLLEXPORT
#endif
#endif // !IRMP_DLLEXPORT


/**
* result data
*/
typedef struct
{
uint32_t protocol; ///< protocol, e.g. NEC_PROTOCOL
const char* protocolName; ///< name of the protocol
uint32_t address; ///< address
uint32_t command; ///< command
uint32_t flags; ///< flags currently only repetition (bit 0)
uint32_t startSample; ///< the sampleindex there the detected command started
uint32_t endSample; ///< the sampleindex there the detected command ended
} IRMP_DataExt;


/**
* Returns the sample rate for that the irmp library was compiled for.
* Any data provided has resamble this sample rate or detection will fail.
*/
IRMP_DLLEXPORT uint32_t IRMP_GetSampleRate(void);

/**
* Resets the internal state of the detector
* This has to be called before start processing data.
*/
IRMP_DLLEXPORT void IRMP_Reset(void);

/**
* Feeds a single sample into the detecor.
* Returns 1 if a ir command was detected.
* Use IRMP_GetData to retrieve the data.
* Make sure, that Reset was called before adding first Sample.
*/
IRMP_DLLEXPORT uint32_t IRMP_AddSample(const uint8_t i_sample);


/**
* Proceses the given buffer and stops on the first found command and returns it data.
* Further calls resume the processing at the previously stopped position.
* Make sure, that Reset was called before first calling Detect.
*/
IRMP_DLLEXPORT IRMP_DataExt IRMP_Detect(const uint8_t* i_buff, uint32_t i_len);


/**
* If a valid IR frame was detected the provided output structure is filled
* \returns 1 if data was available, 0 else
*/
IRMP_DLLEXPORT uint32_t IRMP_GetData(IRMP_DataExt* o_data);

/** returns the the name of the given protocol number */
IRMP_DLLEXPORT const char* IRMP_GetProtocolName(uint32_t i_protocol);


#ifdef __cplusplus
}
#endif

#endif // IRMP_SHARED_H
Loading

0 comments on commit 4c17f5c

Please sign in to comment.