Commit bd1ad9f1 authored by Sven Grabs's avatar Sven Grabs

Praktikum3

parent 2166a1e9
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.187649897">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.187649897" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.187649897" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.187649897." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.1278744543" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
<option id="cdt.managedbuild.option.gnu.cross.prefix.112205105" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-linux-gnueabihf-" valueType="string"/>
<option id="cdt.managedbuild.option.gnu.cross.path.1030640613" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path" useByScannerDiscovery="false" value="/usr/bin" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1879169283" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/Praktikum3}/Debug" id="cdt.managedbuild.builder.gnu.cross.1478604524" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1541402703" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.128495576" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.747816899" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1913025959" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/wiringPi/src/wiringPi}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1335326837" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1983500499" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.492241400" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="gnu.cpp.compiler.option.debugging.level.923866628" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.726744693" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.381547505" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="wiringPi"/>
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="m"/>
<listOptionValue builtIn="false" value="crypt"/>
<listOptionValue builtIn="false" value="rt"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.1024897844" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/wiringPi/Debug}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1132470255" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1653700340" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.2143367177" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.946378643" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1072067483" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.release.2123792837">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.release.2123792837" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.release.2123792837" name="Release" parent="cdt.managedbuild.config.gnu.cross.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.2123792837." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.release.215801911" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
<option id="cdt.managedbuild.option.gnu.cross.prefix.2051288588" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" value="arm-linux-gnueabihf-" valueType="string"/>
<option id="cdt.managedbuild.option.gnu.cross.path.1127317398" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path" value="/usr/bin" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1724939273" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/Praktikum3}/Release" id="cdt.managedbuild.builder.gnu.cross.182016477" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1422761217" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1625143169" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.none" id="gnu.c.compiler.option.debugging.level.953655045" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.470045908" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.857415704" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.594414292" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.none" id="gnu.cpp.compiler.option.debugging.level.1598187415" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1368190555" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.171799845" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1791322311" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1535877374" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.912628866" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2049951518" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Praktikum3.cdt.managedbuild.target.gnu.cross.exe.48394546" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.2123792837;cdt.managedbuild.config.gnu.cross.exe.release.2123792837.;cdt.managedbuild.tool.gnu.cross.c.compiler.1422761217;cdt.managedbuild.tool.gnu.c.compiler.input.470045908">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.187649897;cdt.managedbuild.config.gnu.cross.exe.debug.187649897.;cdt.managedbuild.tool.gnu.cross.c.compiler.1541402703;cdt.managedbuild.tool.gnu.c.compiler.input.1335326837">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Praktikum3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.config.gnu.cross.exe.debug.187649897" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1024866836344712091" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.cross.exe.release.2123792837" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1024866836344712091" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>
\ No newline at end of file
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: Praktikum3
# Tool invocations
Praktikum3: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Cross GCC Linker'
arm-linux-gnueabihf-gcc -L"/home/etiuser/rasp314/wiringPi/Debug" -o "Praktikum3" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) Praktikum3
-@echo ' '
.PHONY: all clean dependents
-include ../makefile.targets
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS := -lwiringPi -lpthread -lm -lcrypt -lrt
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
OBJ_SRCS :=
ASM_SRCS :=
C_SRCS :=
O_SRCS :=
S_UPPER_SRCS :=
EXECUTABLES :=
OBJS :=
C_DEPS :=
# Every subdirectory with source files must be described here
SUBDIRS := \
src \
src/Led.o: ../src/Led.c ../src/Led.h ../src/Makro.h \
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h
../src/Led.h:
../src/Makro.h:
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h:
src/PWMLed.o: ../src/PWMLed.c ../src/Led.h ../src/Makro.h ../src/PWMLed.h \
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h
../src/Led.h:
../src/Makro.h:
../src/PWMLed.h:
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h:
src/main.o: ../src/main.c ../src/Led.h ../src/Makro.h ../src/PWMLed.h \
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h
../src/Led.h:
../src/Makro.h:
../src/PWMLed.h:
/home/etiuser/rasp314/wiringPi/src/wiringPi/wiringPi.h:
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/Led.c \
../src/PWMLed.c \
../src/main.c
OBJS += \
./src/Led.o \
./src/PWMLed.o \
./src/main.o
C_DEPS += \
./src/Led.d \
./src/PWMLed.d \
./src/main.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross GCC Compiler'
arm-linux-gnueabihf-gcc -I"/home/etiuser/rasp314/wiringPi/src/wiringPi" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
/*
* Led.c
*
* Created on: 09.11.2020
* Author: etiuser
*/
#include "Led.h"
#include <stdio.h>
#include <wiringPi.h>
static void on(Led self){
digitalWrite(self->GPIO_Pin, HIGH) ;
self->status = true;
}
static void off(Led self){
digitalWrite(self->GPIO_Pin, LOW) ;
self->status = false;
}
static bool getStatus(Led self){
if(self->status == false) return false;
return true;
}
static LedClass lc = {on, off, getStatus};
Led newLed(int size, ...){
Led self = alloc(Led);
BEG_VARARGS(size);
self->GPIO_Pin = va_arg(sp, int);
END_VARARGS();
wiringPiSetup () ;
pinMode(self->GPIO_Pin, OUTPUT);
digitalWrite(self->GPIO_Pin, LOW) ;
self->status = false;
self->class = &lc;
return self;
}
/*
* Led.h
*
* Created on: 09.11.2020
* Author: etiuser
*/
#ifndef LED_H_
#define LED_H_
#include "Makro.h"
#define actualOn(k) (k)->class->on(((Led)k))
#define actualOff(k) (k)->class->off(((Led)k))
#define actualGetStatus(k) (k)->class->getStatus(((Led)k))
#define ATTRIBUTE_Led() \
int GPIO_Pin; \
bool status;
#define METHODS_Led() \
void (*on)(Led led); \
void (*off)(Led led); \
bool (*getStatus)(Led led);
/*
BEG_DEFINE_CLASS(Led)
METHODS_Led()
END_DEFINE_CLASS(Led)
BEG_DEFINE_INSTANCE(Led)
ATTRIBUTES_Led()
END_DEFINE_INSTANCE(Led)
*/
DEFINE_BASE_TYPE(Led)
#endif /* LED_H_ */
/*
* Makro.h
*
* Created on: 02.11.2020
* Author: etiuser
*/
#include <stdarg.h>
#include <assert.h>
#include <stdlib.h>
#ifndef MAKRO_H_
#define MAKRO_H_
/*#############################################*/
/*# #*/
/*########### Klassen generierung #############*/
#define BEG_DEFINE_CLASS(T) \
typedef struct T##_Instance_struct *T; \
typedef struct T##_Class_struct { \
#define END_DEFINE_CLASS(T) \
}T##Class;
#define BEG_DEFINE_INSTANCE(T) \
typedef struct T##_Instance_struct { \
T##Class *class;
#define END_DEFINE_INSTANCE(T) \
} T##Instance; \
extern T new##T(int size, ...);
#define DEFINE_BASE_TYPE(T) \
BEG_DEFINE_CLASS(T) \
METHODS_##T() \
END_DEFINE_CLASS(T) \
BEG_DEFINE_INSTANCE(T) \
ATTRIBUTE_##T() \
END_DEFINE_INSTANCE(T)
#define DEFINE_EXTENDED_TYPE(T, E) \
BEG_DEFINE_CLASS(T) EXTENDS(E) \
METHODS_##T() \
END_DEFINE_CLASS(T) \
BEG_DEFINE_INSTANCE(T) INSTANCE_OF(E) \
ATTRIBUTE_##T() \
END_DEFINE_INSTANCE(T)
/*#############################################*/
/*# #*/
/*########### Makro für Malloc ################*/
#define alloc(T) \
(T) malloc(sizeof(T##Instance))
/*#############################################*/
/*# #*/
/*################ Vererbung ##################*/
#define EXTENDS(T) \
METHODS_##T()
#define INSTANCE_OF(T) \
ATTRIBUTE_##T()
/*#############################################*/
/*# #*/
/*################# Var Args ##################*/
#define BEG_VARARGS(SIZE) \
va_list sp; \
va_start(sp, SIZE);
#define END_VARARGS() \
va_end(sp);
/*#############################################*/
/*# #*/
/*################# Debug #####################*/
#define DEBUG 1
#ifdef DEBUG
#define debugCon(cond, msg) \
if (!(cond)){ \
printf("%s\n", msg); \
assert(cond); \
}
#define debug(msg) \
printf("%s\n", msg); \
}
#else
#define debugCon(cond, msg)
#define debug(msg)
#endif
/*#############################################*/
/*# #*/
/*################# Boolean ###################*/
typedef enum {false, true}bool;
#endif /* MAKRO_H_ */
/*
* PWMLed.c
*
* Created on: 09.11.2020
* Author: etiuser
*/
#include "Led.h"
#include "PWMLed.h"
#include <stdio.h>
#include <wiringPi.h>
static void on(Led led){
PWMLed self = (PWMLed)led;
self->value = 100;
pwmWrite(self->GPIO_Pin, MAX);
self->status = true;
}
static void off(Led led){
PWMLed self = (PWMLed)led;
self->value = 0;
pwmWrite(self->GPIO_Pin, 0);
self->status = false;
}
static bool getStatus(Led led){
PWMLed self = (PWMLed)led;
if(self->status == false) return false;
return true;
}
static void setValue(PWMLed self, int value){
if(value > 100)value = 0;
else if(value < 0)value = 0;
self->value = value;
pwmWrite(self->GPIO_Pin, value/100.0*MAX);
if(value > 0)self->status = true;
else self->status = false;
}
static int getValue(PWMLed self){
return self->value;
}
static PWMLedClass plc = {on, off, getStatus, setValue, getValue};
PWMLed newPWMLed(int size, ...){
PWMLed self = alloc(PWMLed);
BEG_VARARGS(size);
self->GPIO_Pin = va_arg(sp, int);
self->value = va_arg(sp, int);
END_VARARGS();
wiringPiSetup () ;
pinMode(self->GPIO_Pin, PWM_OUTPUT);
pwmWrite(self->GPIO_Pin, self->value);
if(self->value > 0)self->status = true;
else self->status = false;
self->class = &plc;
return self;
}
/*
* PWMLed.h
*
* Created on: 09.11.2020
* Author: etiuser
*/
#include "Led.h"
#ifndef PWMLED_H_
#define PWMLED_H_
#define MAX 1023
#define actualGetValue(k) (k)->class->getValue(((PWMLed)k))
/*
* @param
* int value erwartet einen Wert zwischen 0 und 100 als Prozentzahl der Helligkeit
*/
#define actualSetValue(k,v) (k)->class->setValue(((PWMLed)k),(v))
#define ATTRIBUTE_PWMLed() \
int value;
#define METHODS_PWMLed() \
void (*setValue)(PWMLed pwmled, int value); \
int (*getValue)(PWMLed pwmled);
DEFINE_EXTENDED_TYPE(PWMLed, Led)
#endif /* PWMLED_H_ */
/*
* main.c
*
* Created on: 09.11.2020
* Author: etiuser
*/
/*
* wiringPi pin 0 = GPIO 17
* wiringPi pin 1 = GPIO 18
* wiringPi pin 2 = GPIO 21
* wiringPi pin 3 = GPIO 22
* wiringPi pin 4 = GPIO 23
* wiringPi pin 5 = GPIO 24
* wiringPi pin 6 = GPIO 25
* wiringPi pin 7 = GPIO 4
*/
#include <stdio.h>
#include "Led.h"