├── CLITool ├── .cproject ├── .project ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.managedbuilder.core.prefs ├── Debug │ ├── CLITool │ ├── makefile │ ├── objects.mk │ ├── sources.mk │ └── src │ │ ├── DisplayNixie.d │ │ ├── DisplayNixie.o │ │ └── subdir.mk └── src │ └── DisplayNixie.cpp ├── Firmware NCS314 HW v2.x ├── .cproject ├── .project ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.managedbuilder.core.prefs ├── Debug │ ├── DisplayNixie │ ├── makefile │ ├── objects.mk │ ├── sources.mk │ └── src │ │ ├── DisplayNixie.d │ │ ├── DisplayNixie.o │ │ └── subdir.mk └── src │ └── DisplayNixie.cpp ├── Firmware NCS314 HW v3.x └── DisplayNixie3x │ ├── .cproject │ ├── .project │ ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.managedbuilder.core.prefs │ ├── Debug │ ├── DisplayNixie3x │ ├── makefile │ ├── objects.mk │ ├── sources.mk │ └── src │ │ ├── DisplayNixie3x.d │ │ ├── DisplayNixie3x.o │ │ └── subdir.mk │ └── src │ └── DisplayNixie3x.cpp ├── Firmware NCS318 └── DisplayNixie │ ├── .cproject │ ├── .project │ ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.managedbuilder.core.prefs │ ├── Debug │ ├── DisplayNixie │ ├── makefile │ ├── objects.mk │ ├── sources.mk │ └── src │ │ ├── DisplayNixie.d │ │ ├── DisplayNixie.o │ │ └── subdir.mk │ └── src │ └── DisplayNixie.cpp └── README.md /CLITool/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /CLITool/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CLITool 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /CLITool/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CLITool/.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/delimiter=\: 3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/delimiter=\: 5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/delimiter=\: 7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/operation=remove 8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/delimiter=\: 11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/operation=remove 12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 14 | -------------------------------------------------------------------------------- /CLITool/Debug/CLITool: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/CLITool/Debug/CLITool -------------------------------------------------------------------------------- /CLITool/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/subdir.mk 12 | -include subdir.mk 13 | -include objects.mk 14 | 15 | ifneq ($(MAKECMDGOALS),clean) 16 | ifneq ($(strip $(CC_DEPS)),) 17 | -include $(CC_DEPS) 18 | endif 19 | ifneq ($(strip $(C++_DEPS)),) 20 | -include $(C++_DEPS) 21 | endif 22 | ifneq ($(strip $(C_UPPER_DEPS)),) 23 | -include $(C_UPPER_DEPS) 24 | endif 25 | ifneq ($(strip $(CXX_DEPS)),) 26 | -include $(CXX_DEPS) 27 | endif 28 | ifneq ($(strip $(C_DEPS)),) 29 | -include $(C_DEPS) 30 | endif 31 | ifneq ($(strip $(CPP_DEPS)),) 32 | -include $(CPP_DEPS) 33 | endif 34 | endif 35 | 36 | -include ../makefile.defs 37 | 38 | # Add inputs and outputs from these tool invocations to the build variables 39 | 40 | # All Target 41 | all: CLITool 42 | 43 | # Tool invocations 44 | CLITool: $(OBJS) $(USER_OBJS) 45 | @echo 'Building target: $@' 46 | @echo 'Invoking: Cross G++ Linker' 47 | g++ -o "CLITool" $(OBJS) $(USER_OBJS) $(LIBS) 48 | @echo 'Finished building target: $@' 49 | @echo ' ' 50 | 51 | # Other Targets 52 | clean: 53 | -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(C_DEPS)$(CPP_DEPS) CLITool 54 | -@echo ' ' 55 | 56 | .PHONY: all clean dependents 57 | .SECONDARY: 58 | 59 | -include ../makefile.targets 60 | -------------------------------------------------------------------------------- /CLITool/Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := -lwiringPi 8 | 9 | -------------------------------------------------------------------------------- /CLITool/Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | C_UPPER_SRCS := 6 | CXX_SRCS := 7 | C++_SRCS := 8 | OBJ_SRCS := 9 | CC_SRCS := 10 | ASM_SRCS := 11 | C_SRCS := 12 | CPP_SRCS := 13 | O_SRCS := 14 | S_UPPER_SRCS := 15 | CC_DEPS := 16 | C++_DEPS := 17 | EXECUTABLES := 18 | OBJS := 19 | C_UPPER_DEPS := 20 | CXX_DEPS := 21 | C_DEPS := 22 | CPP_DEPS := 23 | 24 | # Every subdirectory with source files must be described here 25 | SUBDIRS := \ 26 | src \ 27 | 28 | -------------------------------------------------------------------------------- /CLITool/Debug/src/DisplayNixie.d: -------------------------------------------------------------------------------- 1 | src/DisplayNixie.d: ../src/DisplayNixie.cpp 2 | -------------------------------------------------------------------------------- /CLITool/Debug/src/DisplayNixie.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/CLITool/Debug/src/DisplayNixie.o -------------------------------------------------------------------------------- /CLITool/Debug/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../src/DisplayNixie.cpp 8 | 9 | OBJS += \ 10 | ./src/DisplayNixie.o 11 | 12 | CPP_DEPS += \ 13 | ./src/DisplayNixie.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/%.o: ../src/%.cpp 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: Cross G++ Compiler' 20 | g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /CLITool/src/DisplayNixie.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : DisplayNixie.cpp 3 | // Author : GRA&AFCH 4 | // Version : v1.3 5 | // Copyright : Free 6 | // Description : Display digits on shields 7 | //============================================================================ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define _VERSION 1.3 18 | #define I2CAdress 0x68 19 | #define I2CFlush 0 20 | #define SECOND_REGISTER 0x0 21 | #define MINUTE_REGISTER 0x1 22 | #define HOUR_REGISTER 0x2 23 | 24 | using namespace std; 25 | int LEpin=3; 26 | int I2CFileDesc; 27 | uint16_t SymbolArray[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; 28 | 29 | int decToBcd(int val) { 30 | return ((val / 10 * 16) + (val % 10)); 31 | } 32 | 33 | void writeRTCDate(tm date) { 34 | wiringPiI2CWrite(I2CFileDesc, I2CFlush); 35 | wiringPiI2CWriteReg8(I2CFileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 36 | wiringPiI2CWriteReg8(I2CFileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 37 | wiringPiI2CWriteReg8(I2CFileDesc,SECOND_REGISTER,decToBcd(date.tm_sec)); 38 | wiringPiI2CWrite(I2CFileDesc, I2CFlush); 39 | } 40 | 41 | int main(int argc, char* argv[]) { 42 | printf("Display Nixie CLI Tool v%1.1f \n\r", _VERSION); 43 | printf("%s", argv[1]); 44 | 45 | if (argc < 2) 46 | { 47 | printf("Enter digits to display... or commands: \n now - show current time, \n " 48 | //"clock - loop the program and update time every second, \n " 49 | "[digits] - and six or nine digits, \n " 50 | "settime x - set time, where x time in format [hh:mm:ss], \n " 51 | "setsystime - set current time from OS, \n " 52 | //"ledson - turn on RGB LEDs,\n " 53 | //"ledsoff - turn off RGB LEDs, \n " 54 | //"setledscolor x - set color of LEDs where x is color in [RRR:GGG:BBB] format, \n " 55 | //"setledsbright x - [0...255], \n " 56 | "? - show this help."); 57 | return 0; 58 | } 59 | wiringPiSetup (); 60 | 61 | if (wiringPiSPISetupMode (0, 2000000, 2)) printf("SPI ok\n\r"); 62 | else {printf("SPI NOT ok\n\r"); return 0;} 63 | 64 | I2CFileDesc = wiringPiI2CSetup(I2CAdress); 65 | 66 | char _stringToDisplay[10]; 67 | int tubes_qty=6; 68 | 69 | if (!strcmp(argv[1],"now")) 70 | { 71 | time_t seconds=time(NULL); 72 | tm* timeinfo=localtime(&seconds); 73 | char* format="%H%M%S"; 74 | strftime(_stringToDisplay, 8, format, timeinfo); 75 | } 76 | 77 | else if (!strcmp(argv[1],"settime")) 78 | { 79 | _stringToDisplay[0]=argv[2][0]; 80 | _stringToDisplay[1]=argv[2][1]; 81 | _stringToDisplay[2]=argv[2][3]; 82 | _stringToDisplay[3]=argv[2][4]; 83 | _stringToDisplay[4]=argv[2][6]; 84 | _stringToDisplay[5]=argv[2][7]; 85 | tm time; 86 | time.tm_hour=10*((int)_stringToDisplay[0]-48)+(int)_stringToDisplay[1]-48; 87 | time.tm_min=10*((int)_stringToDisplay[2]-48)+(int)_stringToDisplay[3]-48; 88 | time.tm_sec=10*((int)_stringToDisplay[4]-48)+(int)_stringToDisplay[5]-48; 89 | writeRTCDate(time); 90 | } 91 | 92 | else if (!strcmp(argv[1],"setsystime")) 93 | { 94 | time_t seconds=time(NULL); 95 | tm* time=localtime(&seconds); 96 | writeRTCDate(*time); 97 | char* format="%H%M%S"; 98 | strftime(_stringToDisplay, 8, format, time); 99 | } 100 | 101 | else 102 | { 103 | tubes_qty=strlen(argv[1]); 104 | if ((tubes_qty != 6) && (tubes_qty != 9)) 105 | { 106 | puts("Wrong length: must be 6 or 9 digits. \n"); 107 | return 0; 108 | } 109 | for (int i=0; i>24; 131 | bufferIndex++; 132 | buff[bufferIndex]=Var32>>16; 133 | bufferIndex++; 134 | buff[bufferIndex]=Var32>>8; 135 | bufferIndex++; 136 | buff[bufferIndex]=Var32; 137 | bufferIndex++; 138 | } 139 | 140 | digitalWrite(LEpin, LOW); 141 | wiringPiSPIDataRW(0, buff, 4*tubes_qty/3); 142 | digitalWrite(LEpin, HIGH); 143 | puts("Exit..."); 144 | return 0; 145 | } 146 | 147 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DisplayNixie 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/delimiter=\: 3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/delimiter=\: 5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/delimiter=\: 7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/operation=remove 8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/delimiter=\: 11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/operation=remove 12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 14 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/DisplayNixie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS314 HW v2.x/Debug/DisplayNixie -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/subdir.mk 12 | -include subdir.mk 13 | -include objects.mk 14 | 15 | ifneq ($(MAKECMDGOALS),clean) 16 | ifneq ($(strip $(CC_DEPS)),) 17 | -include $(CC_DEPS) 18 | endif 19 | ifneq ($(strip $(C++_DEPS)),) 20 | -include $(C++_DEPS) 21 | endif 22 | ifneq ($(strip $(C_UPPER_DEPS)),) 23 | -include $(C_UPPER_DEPS) 24 | endif 25 | ifneq ($(strip $(CXX_DEPS)),) 26 | -include $(CXX_DEPS) 27 | endif 28 | ifneq ($(strip $(C_DEPS)),) 29 | -include $(C_DEPS) 30 | endif 31 | ifneq ($(strip $(CPP_DEPS)),) 32 | -include $(CPP_DEPS) 33 | endif 34 | endif 35 | 36 | -include ../makefile.defs 37 | 38 | # Add inputs and outputs from these tool invocations to the build variables 39 | 40 | # All Target 41 | all: DisplayNixie 42 | 43 | # Tool invocations 44 | DisplayNixie: $(OBJS) $(USER_OBJS) 45 | @echo 'Building target: $@' 46 | @echo 'Invoking: Cross G++ Linker' 47 | g++ -o "DisplayNixie" $(OBJS) $(USER_OBJS) $(LIBS) 48 | @echo 'Finished building target: $@' 49 | @echo ' ' 50 | 51 | # Other Targets 52 | clean: 53 | -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(C_DEPS)$(CPP_DEPS) DisplayNixie 54 | -@echo ' ' 55 | 56 | .PHONY: all clean dependents 57 | .SECONDARY: 58 | 59 | -include ../makefile.targets 60 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := -lwiringPi 8 | 9 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | C_UPPER_SRCS := 6 | CXX_SRCS := 7 | C++_SRCS := 8 | OBJ_SRCS := 9 | CC_SRCS := 10 | ASM_SRCS := 11 | C_SRCS := 12 | CPP_SRCS := 13 | O_SRCS := 14 | S_UPPER_SRCS := 15 | CC_DEPS := 16 | C++_DEPS := 17 | EXECUTABLES := 18 | OBJS := 19 | C_UPPER_DEPS := 20 | CXX_DEPS := 21 | C_DEPS := 22 | CPP_DEPS := 23 | 24 | # Every subdirectory with source files must be described here 25 | SUBDIRS := \ 26 | src \ 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/src/DisplayNixie.d: -------------------------------------------------------------------------------- 1 | src/DisplayNixie.d: ../src/DisplayNixie.cpp 2 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/src/DisplayNixie.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS314 HW v2.x/Debug/src/DisplayNixie.o -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/Debug/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../src/DisplayNixie.cpp 8 | 9 | OBJS += \ 10 | ./src/DisplayNixie.o 11 | 12 | CPP_DEPS += \ 13 | ./src/DisplayNixie.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/%.o: ../src/%.cpp 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: Cross G++ Compiler' 20 | g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v2.x/src/DisplayNixie.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : DisplayNixie.cpp 3 | // Author : GRA&AFCH 4 | // Version : v2.3 5 | // Copyright : Free 6 | // Description : Display time on shields NCS314 v2.x or NCS312 7 | //============================================================================ 8 | 9 | #define _VERSION "2.3.1" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | using namespace std; 21 | #define R5222_PIN 22 22 | bool HV5222; 23 | #define LEpin 3 24 | #define UP_BUTTON_PIN 1 25 | #define DOWN_BUTTON_PIN 4 26 | #define MODE_BUTTON_PIN 5 27 | #define BUZZER_PIN 0 28 | #define DS1307_ADDRESS 0x68 29 | #define RV_3028_ADDRESS 0x52 30 | uint8_t RTC_Address; 31 | #define I2CFlush 0 32 | 33 | #define DEBOUNCE_DELAY 150 34 | #define TOTAL_DELAY 17 35 | 36 | #define SECOND_REGISTER 0x0 37 | #define MINUTE_REGISTER 0x1 38 | #define HOUR_REGISTER 0x2 39 | #define WEEK_REGISTER 0x3 40 | #define DAY_REGISTER 0x4 41 | #define MONTH_REGISTER 0x5 42 | #define YEAR_REGISTER 0x6 43 | 44 | #define RED_LIGHT_PIN 28 45 | #define GREEN_LIGHT_PIN 27 46 | #define BLUE_LIGHT_PIN 29 47 | #define MAX_POWER 100 48 | 49 | #define UPPER_DOTS_MASK 0x80000000 50 | #define LOWER_DOTS_MASK 0x40000000 51 | 52 | #define LEFT_REPR_START 5 53 | #define LEFT_BUFFER_START 0 54 | #define RIGHT_REPR_START 2 55 | #define RIGHT_BUFFER_START 4 56 | 57 | uint16_t SymbolArray[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; 58 | 59 | int fileDesc; 60 | int redLight = 100; 61 | int greenLight = 0; 62 | int blueLight = 0; 63 | int lightCycle = 0; 64 | bool dotState = 0; 65 | int rotator = 0; 66 | 67 | int bcdToDec(int val) { 68 | return ((val / 16 * 10) + (val % 16)); 69 | } 70 | 71 | int decToBcd(int val) { 72 | return ((val / 10 * 16) + (val % 10)); 73 | } 74 | 75 | tm addHourToDate(tm date) { 76 | date.tm_hour += 1; 77 | mktime(&date); 78 | return date; 79 | } 80 | 81 | tm addMinuteToDate(tm date) { 82 | date.tm_min += 1; 83 | mktime(&date); 84 | return date; 85 | } 86 | 87 | tm getRTCDate() { 88 | wiringPiI2CWrite(fileDesc, I2CFlush); 89 | tm date; 90 | date.tm_sec = bcdToDec(wiringPiI2CReadReg8(fileDesc,SECOND_REGISTER)); 91 | date.tm_min = bcdToDec(wiringPiI2CReadReg8(fileDesc,MINUTE_REGISTER)); 92 | date.tm_hour = bcdToDec(wiringPiI2CReadReg8(fileDesc,HOUR_REGISTER)); 93 | date.tm_wday = bcdToDec(wiringPiI2CReadReg8(fileDesc,WEEK_REGISTER)); 94 | date.tm_mday = bcdToDec(wiringPiI2CReadReg8(fileDesc,DAY_REGISTER)); 95 | date.tm_mon = bcdToDec(wiringPiI2CReadReg8(fileDesc,MONTH_REGISTER)); 96 | date.tm_year = bcdToDec(wiringPiI2CReadReg8(fileDesc,YEAR_REGISTER)); 97 | date.tm_isdst = 0; 98 | return date; 99 | } 100 | 101 | void updateRTCHour(tm date) { 102 | wiringPiI2CWrite(fileDesc, I2CFlush); 103 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 104 | wiringPiI2CWrite(fileDesc, I2CFlush); 105 | } 106 | 107 | void updateRTCMinute(tm date) { 108 | wiringPiI2CWrite(fileDesc, I2CFlush); 109 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 110 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 111 | wiringPiI2CWrite(fileDesc, I2CFlush); 112 | } 113 | void resetRTCSecond() { 114 | wiringPiI2CWrite(fileDesc, I2CFlush); 115 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER, 0); 116 | wiringPiI2CWrite(fileDesc, I2CFlush); 117 | } 118 | 119 | void writeRTCDate(tm date) { 120 | wiringPiI2CWrite(fileDesc, I2CFlush); 121 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER,decToBcd(date.tm_sec)); 122 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 123 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 124 | wiringPiI2CWriteReg8(fileDesc,WEEK_REGISTER,decToBcd(date.tm_wday)); 125 | wiringPiI2CWriteReg8(fileDesc,DAY_REGISTER,decToBcd(date.tm_mday)); 126 | wiringPiI2CWriteReg8(fileDesc,MONTH_REGISTER,decToBcd(date.tm_mon)); 127 | wiringPiI2CWriteReg8(fileDesc,YEAR_REGISTER,decToBcd(date.tm_year)); 128 | wiringPiI2CWrite(fileDesc, I2CFlush); 129 | } 130 | 131 | void initPin(int pin) { 132 | pinMode(pin, INPUT); 133 | pullUpDnControl(pin, PUD_UP); 134 | 135 | } 136 | 137 | void funcMode(void) { 138 | static unsigned long modeTime = 0; 139 | if ((millis() - modeTime) > DEBOUNCE_DELAY) { 140 | puts("MODE button was pressed."); 141 | resetRTCSecond(); 142 | modeTime = millis(); 143 | } 144 | } 145 | 146 | 147 | 148 | uint32_t get32Rep(char * _stringToDisplay, int start) { 149 | uint32_t var32 = 0; 150 | 151 | var32= (SymbolArray[_stringToDisplay[start]-0x30])<<20; 152 | var32|=(SymbolArray[_stringToDisplay[start - 1]-0x30])<<10; 153 | var32|=(SymbolArray[_stringToDisplay[start - 2]-0x30]); 154 | return var32; 155 | } 156 | 157 | void fillBuffer(uint32_t var32, unsigned char * buffer, int start) { 158 | buffer[start] = var32>>24; 159 | buffer[start + 1] = var32>>16; 160 | buffer[start + 2] = var32>>8; 161 | buffer[start + 3] = var32; 162 | } 163 | 164 | void dotBlink() 165 | { 166 | static unsigned int lastTimeBlink=millis(); 167 | 168 | if ((millis() - lastTimeBlink) > 1000) 169 | { 170 | lastTimeBlink=millis(); 171 | dotState = !dotState; 172 | } 173 | } 174 | 175 | void rotateFireWorks() { 176 | int fireworks[] = {0,0,1, 177 | -1,0,0, 178 | 0,1,0, 179 | 0,0,-1, 180 | 1,0,0, 181 | 0,-1,0 182 | }; 183 | redLight += fireworks[rotator * 3]; 184 | greenLight += fireworks[rotator * 3 + 1]; 185 | blueLight += fireworks[rotator * 3 + 2]; 186 | softPwmWrite(RED_LIGHT_PIN, redLight); 187 | softPwmWrite(GREEN_LIGHT_PIN, greenLight); 188 | softPwmWrite(BLUE_LIGHT_PIN, blueLight); 189 | lightCycle = lightCycle + 1; 190 | if (lightCycle == MAX_POWER) { 191 | rotator = rotator + 1; 192 | lightCycle = 0; 193 | } 194 | if (rotator > 5) 195 | rotator = 0; 196 | } 197 | 198 | uint32_t addBlinkTo32Rep(uint32_t var) { 199 | if (dotState) 200 | { 201 | var &=~LOWER_DOTS_MASK; 202 | var &=~UPPER_DOTS_MASK; 203 | } 204 | else 205 | { 206 | var |=LOWER_DOTS_MASK; 207 | var |=UPPER_DOTS_MASK; 208 | } 209 | return var; 210 | } 211 | 212 | //uint64_t* reverseBit(uint64_t num); 213 | uint64_t reverseBit(uint64_t num); 214 | void RTC_Test() 215 | { 216 | uint8_t errorCounter = 0; 217 | int8_t DS3231InternalTemperature = 0; 218 | RTC_Address = DS1307_ADDRESS; 219 | fileDesc = wiringPiI2CSetup(RTC_Address); 220 | 221 | DS3231InternalTemperature = wiringPiI2CReadReg16(fileDesc, 0x11); 222 | wiringPiI2CWrite(fileDesc, I2CFlush); 223 | 224 | printf("DS3231_T=%i\n\r", DS3231InternalTemperature); 225 | if ((DS3231InternalTemperature < 5) || (DS3231InternalTemperature > 60)) 226 | { 227 | errorCounter++; 228 | RTC_Address = RV_3028_ADDRESS; 229 | } 230 | 231 | fileDesc = wiringPiI2CSetup(RTC_Address); 232 | 233 | if (wiringPiI2CReadReg8(fileDesc, 28) <= 0) 234 | { 235 | errorCounter++; 236 | } 237 | 238 | if (errorCounter == 2) 239 | { 240 | puts("Faulty RTC!"); 241 | return; 242 | } 243 | 244 | wiringPiI2CWrite(fileDesc, 0x0F); 245 | wiringPiI2CWrite(fileDesc, 0x08); 246 | wiringPiI2CWrite(fileDesc, 0x37); 247 | wiringPiI2CWrite(fileDesc, 0x1C); 248 | wiringPiI2CWrite(fileDesc, 0x27); 249 | wiringPiI2CWrite(fileDesc, 0x00); 250 | wiringPiI2CWrite(fileDesc, 0x27); 251 | wiringPiI2CWrite(fileDesc, 0x11); 252 | wiringPiI2CWrite(fileDesc, 0x0F); 253 | wiringPiI2CWrite(fileDesc, 0x00); 254 | wiringPiI2CWrite(fileDesc, 0x0E); 255 | wiringPiI2CWrite(fileDesc, 0x00); 256 | 257 | } 258 | 259 | int main(int argc, char* argv[]) { 260 | printf("Nixie Clock v%s \n\r", _VERSION); 261 | wiringPiSetup(); 262 | //softToneCreate (BUZZER_PIN); 263 | //softToneWrite(BUZZER_PIN, 1000); 264 | softPwmCreate(RED_LIGHT_PIN, 100, MAX_POWER); 265 | softPwmCreate(GREEN_LIGHT_PIN, 0, MAX_POWER); 266 | softPwmCreate(BLUE_LIGHT_PIN, 0, MAX_POWER); 267 | initPin(UP_BUTTON_PIN); 268 | initPin(DOWN_BUTTON_PIN); 269 | initPin(MODE_BUTTON_PIN); 270 | //wiringPiISR(MODE_BUTTON_PIN,INT_EDGE_RISING,&funcMode); 271 | RTC_Test(); 272 | fileDesc = wiringPiI2CSetup(RTC_Address); 273 | 274 | tm date = getRTCDate(); 275 | time_t seconds = time(NULL); 276 | tm* timeinfo = localtime (&seconds); 277 | date.tm_mday = timeinfo->tm_mday; 278 | date.tm_wday = timeinfo->tm_wday; 279 | date.tm_mon = timeinfo->tm_mon + 1; 280 | date.tm_year = timeinfo->tm_year - 100; 281 | writeRTCDate(date); 282 | 283 | if (wiringPiSPISetupMode (0, 2000000, 2)) { 284 | puts("SPI ok"); 285 | } 286 | else { 287 | puts("SPI NOT ok"); 288 | return 0; 289 | } 290 | 291 | pinMode(R5222_PIN, INPUT); 292 | pullUpDnControl(R5222_PIN, PUD_UP); 293 | HV5222=!digitalRead(R5222_PIN); 294 | if (HV5222) puts("R52222 resistor detected. HV5222 algorithm is used."); 295 | uint64_t reverseBuffValue; 296 | 297 | long hourDelay = millis(); 298 | long minuteDelay = hourDelay; 299 | long modeDelay = hourDelay; 300 | do { 301 | char _stringToDisplay[8]; 302 | date = getRTCDate(); 303 | char* format ="%H%M%S"; 304 | strftime(_stringToDisplay, 8, format, &date); 305 | 306 | //printf("string=%s", _stringToDisplay); 307 | 308 | pinMode(LEpin, OUTPUT); 309 | dotBlink(); 310 | 311 | unsigned char buff[8]; 312 | 313 | uint32_t var32 = get32Rep(_stringToDisplay, LEFT_REPR_START); 314 | var32 = addBlinkTo32Rep(var32); 315 | 316 | fillBuffer(var32, buff , LEFT_BUFFER_START); 317 | 318 | var32 = get32Rep(_stringToDisplay, RIGHT_REPR_START); 319 | var32 = addBlinkTo32Rep(var32); 320 | 321 | fillBuffer(var32, buff , RIGHT_BUFFER_START); 322 | 323 | if (digitalRead(UP_BUTTON_PIN) == 0 && (millis() - hourDelay) > DEBOUNCE_DELAY) { 324 | updateRTCHour(addHourToDate(date)); 325 | hourDelay = millis(); 326 | } 327 | if (digitalRead(DOWN_BUTTON_PIN) == 0 && (millis() - minuteDelay) > DEBOUNCE_DELAY) { 328 | updateRTCMinute(addMinuteToDate(date)); 329 | minuteDelay = millis(); 330 | } 331 | if (digitalRead(MODE_BUTTON_PIN) == 0 && (millis() - modeDelay) > DEBOUNCE_DELAY) { 332 | resetRTCSecond(); 333 | modeDelay = millis(); 334 | } 335 | 336 | rotateFireWorks(); 337 | digitalWrite(LEpin, LOW); 338 | 339 | if (HV5222) 340 | { 341 | reverseBuffValue=reverseBit(*(uint64_t*)buff); 342 | buff[4]=reverseBuffValue; 343 | buff[5]=reverseBuffValue>>8; 344 | buff[6]=reverseBuffValue>>16; 345 | buff[7]=reverseBuffValue>>24; 346 | buff[0]=reverseBuffValue>>32; 347 | buff[1]=reverseBuffValue>>40; 348 | buff[2]=reverseBuffValue>>48; 349 | buff[3]=reverseBuffValue>>56; 350 | } 351 | 352 | wiringPiSPIDataRW(0, buff, 8); 353 | digitalWrite(LEpin, HIGH); 354 | delay (TOTAL_DELAY); 355 | } 356 | while (true); 357 | return 0; 358 | } 359 | 360 | //uint64_t* reverseBit(uint64_t num) 361 | uint64_t reverseBit(uint64_t num) 362 | { 363 | uint64_t reverse_num=0; 364 | int i; 365 | for (i=0; i<64; i++) 366 | { 367 | if ((num & ((uint64_t)1< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DisplayNixie3x 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/delimiter=\: 3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/delimiter=\: 5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/delimiter=\: 7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/operation=remove 8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/delimiter=\: 11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/operation=remove 12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 14 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/DisplayNixie3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/DisplayNixie3x -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/subdir.mk 12 | -include subdir.mk 13 | -include objects.mk 14 | 15 | ifneq ($(MAKECMDGOALS),clean) 16 | ifneq ($(strip $(CC_DEPS)),) 17 | -include $(CC_DEPS) 18 | endif 19 | ifneq ($(strip $(C++_DEPS)),) 20 | -include $(C++_DEPS) 21 | endif 22 | ifneq ($(strip $(C_UPPER_DEPS)),) 23 | -include $(C_UPPER_DEPS) 24 | endif 25 | ifneq ($(strip $(CXX_DEPS)),) 26 | -include $(CXX_DEPS) 27 | endif 28 | ifneq ($(strip $(C_DEPS)),) 29 | -include $(C_DEPS) 30 | endif 31 | ifneq ($(strip $(CPP_DEPS)),) 32 | -include $(CPP_DEPS) 33 | endif 34 | endif 35 | 36 | -include ../makefile.defs 37 | 38 | # Add inputs and outputs from these tool invocations to the build variables 39 | 40 | # All Target 41 | all: DisplayNixie3x 42 | 43 | # Tool invocations 44 | DisplayNixie3x: $(OBJS) $(USER_OBJS) 45 | @echo 'Building target: $@' 46 | @echo 'Invoking: Cross G++ Linker' 47 | g++ -o "DisplayNixie3x" $(OBJS) $(USER_OBJS) $(LIBS) 48 | @echo 'Finished building target: $@' 49 | @echo ' ' 50 | 51 | # Other Targets 52 | clean: 53 | -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(C_DEPS)$(CPP_DEPS) DisplayNixie3x 54 | -@echo ' ' 55 | 56 | .PHONY: all clean dependents 57 | .SECONDARY: 58 | 59 | -include ../makefile.targets 60 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := -lwiringPi 8 | 9 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | C_UPPER_SRCS := 6 | CXX_SRCS := 7 | C++_SRCS := 8 | OBJ_SRCS := 9 | CC_SRCS := 10 | ASM_SRCS := 11 | C_SRCS := 12 | CPP_SRCS := 13 | O_SRCS := 14 | S_UPPER_SRCS := 15 | CC_DEPS := 16 | C++_DEPS := 17 | EXECUTABLES := 18 | OBJS := 19 | C_UPPER_DEPS := 20 | CXX_DEPS := 21 | C_DEPS := 22 | CPP_DEPS := 23 | 24 | # Every subdirectory with source files must be described here 25 | SUBDIRS := \ 26 | src \ 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/src/DisplayNixie3x.d: -------------------------------------------------------------------------------- 1 | src/DisplayNixie3x.d: ../src/DisplayNixie3x.cpp 2 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/src/DisplayNixie3x.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/src/DisplayNixie3x.o -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/Debug/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../src/DisplayNixie3x.cpp 8 | 9 | OBJS += \ 10 | ./src/DisplayNixie3x.o 11 | 12 | CPP_DEPS += \ 13 | ./src/DisplayNixie3x.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/%.o: ../src/%.cpp 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: Cross G++ Compiler' 20 | g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Firmware NCS314 HW v3.x/DisplayNixie3x/src/DisplayNixie3x.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : DisplayNixie.cpp 3 | // Author : GRA&AFCH 4 | // Version : v1.0 5 | // Copyright : Free 6 | // Description : Display time on shields NCS314 v3.x 7 | // Date : 27.04.2020 8 | //============================================================================ 9 | 10 | #define _VERSION "1.1 for NCS314 HW Version 3.x" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 23 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) 24 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 25 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 26 | 27 | using namespace std; 28 | #define LEpin 3 29 | #define SHDNpin 2 30 | #define UP_BUTTON_PIN 1 31 | #define DOWN_BUTTON_PIN 4 32 | #define MODE_BUTTON_PIN 5 33 | #define BUZZER_PIN 0 34 | #define DS1307_ADDRESS 0x68 35 | #define RV_3028_ADDRESS 0x52 36 | uint8_t RTC_Address; 37 | #define I2CFlush 0 38 | 39 | #define DEBOUNCE_DELAY 150 40 | #define TOTAL_DELAY 17 41 | 42 | #define SECOND_REGISTER 0x0 43 | #define MINUTE_REGISTER 0x1 44 | #define HOUR_REGISTER 0x2 45 | #define WEEK_REGISTER 0x3 46 | #define DAY_REGISTER 0x4 47 | #define MONTH_REGISTER 0x5 48 | #define YEAR_REGISTER 0x6 49 | 50 | #define RED_LIGHT_PIN 28 51 | #define GREEN_LIGHT_PIN 27 52 | #define BLUE_LIGHT_PIN 29 53 | #define MAX_POWER 100 54 | 55 | #define UPPER_DOTS_MASK 0x80000000 56 | #define LOWER_DOTS_MASK 0x40000000 57 | 58 | #define LEFT_REPR_START 5 59 | #define LEFT_BUFFER_START 0 60 | #define RIGHT_REPR_START 2 61 | #define RIGHT_BUFFER_START 4 62 | 63 | uint16_t SymbolArray[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; 64 | 65 | int fileDesc; 66 | int redLight = 100; 67 | int greenLight = 0; 68 | int blueLight = 0; 69 | int lightCycle = 0; 70 | bool dotState = 0; 71 | int rotator = 0; 72 | 73 | int bcdToDec(int val) { 74 | return ((val / 16 * 10) + (val % 16)); 75 | } 76 | 77 | int decToBcd(int val) { 78 | return ((val / 10 * 16) + (val % 10)); 79 | } 80 | 81 | tm addHourToDate(tm date) { 82 | date.tm_hour += 1; 83 | mktime(&date); 84 | return date; 85 | } 86 | 87 | tm addMinuteToDate(tm date) { 88 | date.tm_min += 1; 89 | mktime(&date); 90 | return date; 91 | } 92 | 93 | tm getRTCDate() { 94 | wiringPiI2CWrite(fileDesc, I2CFlush); 95 | tm date; 96 | date.tm_sec = bcdToDec(wiringPiI2CReadReg8(fileDesc,SECOND_REGISTER)); 97 | date.tm_min = bcdToDec(wiringPiI2CReadReg8(fileDesc,MINUTE_REGISTER)); 98 | date.tm_hour = bcdToDec(wiringPiI2CReadReg8(fileDesc,HOUR_REGISTER)); 99 | date.tm_wday = bcdToDec(wiringPiI2CReadReg8(fileDesc,WEEK_REGISTER)); 100 | date.tm_mday = bcdToDec(wiringPiI2CReadReg8(fileDesc,DAY_REGISTER)); 101 | date.tm_mon = bcdToDec(wiringPiI2CReadReg8(fileDesc,MONTH_REGISTER)); 102 | date.tm_year = bcdToDec(wiringPiI2CReadReg8(fileDesc,YEAR_REGISTER)); 103 | date.tm_isdst = 0; 104 | return date; 105 | } 106 | 107 | void updateRTCHour(tm date) { 108 | wiringPiI2CWrite(fileDesc, I2CFlush); 109 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 110 | wiringPiI2CWrite(fileDesc, I2CFlush); 111 | } 112 | 113 | void updateRTCMinute(tm date) { 114 | wiringPiI2CWrite(fileDesc, I2CFlush); 115 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 116 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 117 | wiringPiI2CWrite(fileDesc, I2CFlush); 118 | } 119 | void resetRTCSecond() { 120 | wiringPiI2CWrite(fileDesc, I2CFlush); 121 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER, 0); 122 | wiringPiI2CWrite(fileDesc, I2CFlush); 123 | } 124 | 125 | void writeRTCDate(tm date) { 126 | wiringPiI2CWrite(fileDesc, I2CFlush); 127 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER,decToBcd(date.tm_sec)); 128 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 129 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 130 | wiringPiI2CWriteReg8(fileDesc,WEEK_REGISTER,decToBcd(date.tm_wday)); 131 | wiringPiI2CWriteReg8(fileDesc,DAY_REGISTER,decToBcd(date.tm_mday)); 132 | wiringPiI2CWriteReg8(fileDesc,MONTH_REGISTER,decToBcd(date.tm_mon)); 133 | wiringPiI2CWriteReg8(fileDesc,YEAR_REGISTER,decToBcd(date.tm_year)); 134 | wiringPiI2CWrite(fileDesc, I2CFlush); 135 | } 136 | 137 | void initPin(int pin) { 138 | pinMode(pin, INPUT); 139 | pullUpDnControl(pin, PUD_UP); 140 | 141 | } 142 | 143 | void funcMode(void) { 144 | static unsigned long modeTime = 0; 145 | if ((millis() - modeTime) > DEBOUNCE_DELAY) { 146 | puts("MODE button was pressed."); 147 | resetRTCSecond(); 148 | modeTime = millis(); 149 | } 150 | } 151 | 152 | void dotBlink() 153 | { 154 | static unsigned int lastTimeBlink=millis(); 155 | 156 | if ((millis() - lastTimeBlink) > 1000) 157 | { 158 | lastTimeBlink=millis(); 159 | dotState = !dotState; 160 | } 161 | } 162 | 163 | /*void rotateFireWorks() { 164 | int fireworks[] = {0,0,1, 165 | -1,0,0, 166 | 0,1,0, 167 | 0,0,-1, 168 | 1,0,0, 169 | 0,-1,0 170 | }; 171 | redLight += fireworks[rotator * 3]; 172 | greenLight += fireworks[rotator * 3 + 1]; 173 | blueLight += fireworks[rotator * 3 + 2]; 174 | softPwmWrite(RED_LIGHT_PIN, redLight); 175 | softPwmWrite(GREEN_LIGHT_PIN, greenLight); 176 | softPwmWrite(BLUE_LIGHT_PIN, blueLight); 177 | lightCycle = lightCycle + 1; 178 | if (lightCycle == MAX_POWER) { 179 | rotator = rotator + 1; 180 | lightCycle = 0; 181 | } 182 | if (rotator > 5) 183 | rotator = 0; 184 | }*/ 185 | 186 | uint32_t get32Rep(char * _stringToDisplay, int start) { 187 | uint32_t var32 = 0; 188 | 189 | var32= (SymbolArray[_stringToDisplay[start]-0x30])<<20; 190 | var32|=(SymbolArray[_stringToDisplay[start - 1]-0x30])<<10; 191 | var32|=(SymbolArray[_stringToDisplay[start - 2]-0x30]); 192 | return var32; 193 | } 194 | 195 | void fillBuffer(uint32_t var32, unsigned char * buffer, int start) { 196 | 197 | buffer[start] = var32>>24; 198 | buffer[start + 1] = var32>>16; 199 | buffer[start + 2] = var32>>8; 200 | buffer[start + 3] = var32; 201 | } 202 | 203 | 204 | uint32_t addBlinkTo32Rep(uint32_t var) { 205 | if (dotState) 206 | { 207 | var &=~LOWER_DOTS_MASK; 208 | var &=~UPPER_DOTS_MASK; 209 | } 210 | else 211 | { 212 | var |=LOWER_DOTS_MASK; 213 | var |=UPPER_DOTS_MASK; 214 | } 215 | return var; 216 | } 217 | 218 | char _stringToDisplay[8]; 219 | void doIndication(); 220 | 221 | void RTC_Test() 222 | { 223 | uint8_t errorCounter = 0; 224 | int8_t DS3231InternalTemperature = 0; 225 | RTC_Address = DS1307_ADDRESS; 226 | fileDesc = wiringPiI2CSetup(RTC_Address); 227 | 228 | DS3231InternalTemperature = wiringPiI2CReadReg16(fileDesc, 0x11); 229 | wiringPiI2CWrite(fileDesc, I2CFlush); 230 | 231 | printf("DS3231_T=%i\n\r", DS3231InternalTemperature); 232 | if ((DS3231InternalTemperature < 5) || (DS3231InternalTemperature > 60)) 233 | { 234 | errorCounter++; 235 | RTC_Address = RV_3028_ADDRESS; 236 | } 237 | 238 | fileDesc = wiringPiI2CSetup(RTC_Address); 239 | 240 | if (wiringPiI2CReadReg8(fileDesc, 28) <= 0) 241 | { 242 | errorCounter++; 243 | } 244 | 245 | if (errorCounter == 2) 246 | { 247 | puts("Faulty RTC!"); 248 | return; 249 | } 250 | 251 | wiringPiI2CWrite(fileDesc, 0x0F); 252 | wiringPiI2CWrite(fileDesc, 0x08); 253 | wiringPiI2CWrite(fileDesc, 0x37); 254 | wiringPiI2CWrite(fileDesc, 0x1C); 255 | wiringPiI2CWrite(fileDesc, 0x27); 256 | wiringPiI2CWrite(fileDesc, 0x00); 257 | wiringPiI2CWrite(fileDesc, 0x27); 258 | wiringPiI2CWrite(fileDesc, 0x11); 259 | wiringPiI2CWrite(fileDesc, 0x0F); 260 | wiringPiI2CWrite(fileDesc, 0x00); 261 | wiringPiI2CWrite(fileDesc, 0x0E); 262 | wiringPiI2CWrite(fileDesc, 0x00); 263 | 264 | } 265 | 266 | int main(int argc, char* argv[]) { 267 | printf("Nixie Clock v%s \n\r", _VERSION); 268 | wiringPiSetup(); 269 | //softToneCreate (BUZZER_PIN); 270 | //softToneWrite(BUZZER_PIN, 1000); 271 | softPwmCreate(RED_LIGHT_PIN, 100, MAX_POWER); 272 | softPwmCreate(GREEN_LIGHT_PIN, 0, MAX_POWER); 273 | softPwmCreate(BLUE_LIGHT_PIN, 0, MAX_POWER); 274 | initPin(UP_BUTTON_PIN); 275 | initPin(DOWN_BUTTON_PIN); 276 | initPin(MODE_BUTTON_PIN); 277 | wiringPiISR(MODE_BUTTON_PIN,INT_EDGE_RISING,&funcMode); 278 | RTC_Test(); 279 | fileDesc = wiringPiI2CSetup(RTC_Address); 280 | 281 | tm date = getRTCDate(); 282 | time_t seconds = time(NULL); 283 | tm* timeinfo = localtime (&seconds); 284 | date.tm_mday = timeinfo->tm_mday; 285 | date.tm_wday = timeinfo->tm_wday; 286 | date.tm_mon = timeinfo->tm_mon + 1; 287 | date.tm_year = timeinfo->tm_year - 100; 288 | writeRTCDate(date); 289 | 290 | if (wiringPiSPISetupMode (0, 500000, 3)) { // 1 - Arduino Photo, 3 - Production 291 | puts("SPI ok"); 292 | } 293 | else { 294 | puts("SPI NOT ok"); 295 | return 0; 296 | } 297 | 298 | pinMode(SHDNpin, OUTPUT); 299 | digitalWrite(SHDNpin, HIGH); //HIGH = ON 300 | 301 | long hourDelay = millis(); 302 | long minuteDelay = hourDelay; 303 | do { 304 | //char _stringToDisplay[8]; 305 | date = getRTCDate(); 306 | char* format ="%H%M%S"; 307 | strftime(_stringToDisplay, 8, format, &date); 308 | 309 | 310 | pinMode(LEpin, OUTPUT); 311 | dotBlink(); 312 | 313 | doIndication(); 314 | 315 | if (digitalRead(UP_BUTTON_PIN) == 0 && (millis() - hourDelay) > DEBOUNCE_DELAY) { 316 | updateRTCHour(addHourToDate(date)); 317 | hourDelay = millis(); 318 | } 319 | if (digitalRead(DOWN_BUTTON_PIN) == 0 && (millis() - minuteDelay) > DEBOUNCE_DELAY) { 320 | updateRTCMinute(addMinuteToDate(date)); 321 | minuteDelay = millis(); 322 | } 323 | 324 | // rotateFireWorks(); 325 | 326 | delay (TOTAL_DELAY); 327 | } 328 | while (true); 329 | return 0; 330 | } 331 | 332 | 333 | #define UpperDotsMask 0x80000000 334 | #define LowerDotsMask 0x40000000 335 | 336 | void doIndication() 337 | { 338 | 339 | // digitalWrite(LEpin, LOW); //<<-- H -> L 340 | //dotState=false; //delete 341 | unsigned long Var32=0; 342 | unsigned long New32_L=0; 343 | unsigned long New32_H=0; 344 | unsigned char buff[8]; 345 | 346 | long digits=atoi(_stringToDisplay); //uncomment 347 | //digits=235640; //delete 348 | 349 | 350 | /********************************************************** 351 | * Data format incomin [H1][H2][M1][M2][S1][S2] 352 | *********************************************************/ 353 | 354 | //-------- REG 1 ----------------------------------------------- 355 | Var32=0; 356 | 357 | Var32|=(unsigned long)(SymbolArray[digits%10])<<20; // s2 358 | digits=digits/10; 359 | 360 | Var32|=(unsigned long)(SymbolArray[digits%10])<<10; //s1 361 | digits=digits/10; 362 | 363 | Var32|=(unsigned long)(SymbolArray[digits%10]); //m2 364 | digits=digits/10; 365 | 366 | if (dotState) Var32|=LowerDotsMask; 367 | else Var32&=~LowerDotsMask; 368 | 369 | if (dotState) Var32|=UpperDotsMask; 370 | else Var32&=~UpperDotsMask; 371 | 372 | for (int i=1; i<=32; i++) 373 | { 374 | i=i+32; 375 | int newindex=16*(3-(ceil((float)i/4)*4-i))+ceil((float)i/4); 376 | i=i-32; 377 | if (newindex<=32) bitWrite(New32_L, newindex-1, bitRead(Var32, i-1)); 378 | else bitWrite(New32_H, newindex-32-1, bitRead(Var32, i-1)); 379 | } 380 | //------------------------------------------------------------------------- 381 | 382 | //-------- REG 0 ----------------------------------------------- 383 | Var32=0; 384 | 385 | Var32|=(unsigned long)(SymbolArray[digits%10])<<20; // m1 386 | digits=digits/10; 387 | 388 | Var32|= (unsigned long)(SymbolArray[digits%10])<<10; //h2 389 | digits=digits/10; 390 | 391 | Var32|= (unsigned long)SymbolArray[digits%10]; //h1 392 | digits=digits/10; 393 | 394 | if (dotState) Var32|=LowerDotsMask; 395 | else Var32&=~LowerDotsMask; 396 | 397 | if (dotState) Var32|=UpperDotsMask; 398 | else Var32&=~UpperDotsMask; 399 | 400 | for (int i=1; i<=32; i++) 401 | { 402 | int newindex=16*(3-(ceil((float)i/4)*4-i))+ceil((float)i/4); 403 | if (newindex<=32) bitWrite(New32_L, newindex-1, bitRead(Var32, i-1)); 404 | else bitWrite(New32_H, newindex-32-1, bitRead(Var32, i-1)); 405 | } 406 | 407 | buff[0] = New32_H>>24; 408 | buff[1] = New32_H>>16; 409 | buff[2] = New32_H>>8; 410 | buff[3] = New32_H; 411 | 412 | buff[4] = New32_L>>24; 413 | buff[5] = New32_L>>16; 414 | buff[6] = New32_L>>8; 415 | buff[7] = New32_L; 416 | 417 | 418 | /*buff[0] = 0; 419 | buff[1] = 0; 420 | buff[2] = 0; 421 | buff[3] = 0; 422 | 423 | buff[4] = 0; 424 | buff[5] = 0; 425 | buff[6] = 0; 426 | buff[7] = 0;*/ 427 | //digitalWrite(LEpin, LOW); //<<-- H -> L 428 | 429 | wiringPiSPIDataRW(0, buff, 8); 430 | 431 | digitalWrite(LEpin, HIGH); // <<-- H -> L 432 | 433 | int x; //delete 434 | for (int i=0; i<23; i++) 435 | { 436 | x=sin(i); 437 | } 438 | x+x+1; 439 | 440 | digitalWrite(LEpin, LOW); //<<-- H -> L 441 | 442 | delay(20); 443 | 444 | //while(1); 445 | //------------------------------------------------------------------------- 446 | } 447 | 448 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DisplayNixie 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/delimiter=\: 3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/delimiter=\: 5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/CPLUS_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/delimiter=\: 7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/C_INCLUDE_PATH/operation=remove 8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/delimiter=\: 11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/LIBRARY_PATH/operation=remove 12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/append=true 13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.cross.exe.debug.493283321/appendContributed=true 14 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/DisplayNixie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS318/DisplayNixie/Debug/DisplayNixie -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/subdir.mk 12 | -include subdir.mk 13 | -include objects.mk 14 | 15 | ifneq ($(MAKECMDGOALS),clean) 16 | ifneq ($(strip $(CC_DEPS)),) 17 | -include $(CC_DEPS) 18 | endif 19 | ifneq ($(strip $(C++_DEPS)),) 20 | -include $(C++_DEPS) 21 | endif 22 | ifneq ($(strip $(C_UPPER_DEPS)),) 23 | -include $(C_UPPER_DEPS) 24 | endif 25 | ifneq ($(strip $(CXX_DEPS)),) 26 | -include $(CXX_DEPS) 27 | endif 28 | ifneq ($(strip $(C_DEPS)),) 29 | -include $(C_DEPS) 30 | endif 31 | ifneq ($(strip $(CPP_DEPS)),) 32 | -include $(CPP_DEPS) 33 | endif 34 | endif 35 | 36 | -include ../makefile.defs 37 | 38 | # Add inputs and outputs from these tool invocations to the build variables 39 | 40 | # All Target 41 | all: DisplayNixie 42 | 43 | # Tool invocations 44 | DisplayNixie: $(OBJS) $(USER_OBJS) 45 | @echo 'Building target: $@' 46 | @echo 'Invoking: Cross G++ Linker' 47 | g++ -o "DisplayNixie" $(OBJS) $(USER_OBJS) $(LIBS) 48 | @echo 'Finished building target: $@' 49 | @echo ' ' 50 | 51 | # Other Targets 52 | clean: 53 | -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(C_DEPS)$(CPP_DEPS) DisplayNixie 54 | -@echo ' ' 55 | 56 | .PHONY: all clean dependents 57 | .SECONDARY: 58 | 59 | -include ../makefile.targets 60 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := -lwiringPi 8 | 9 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | C_UPPER_SRCS := 6 | CXX_SRCS := 7 | C++_SRCS := 8 | OBJ_SRCS := 9 | CC_SRCS := 10 | ASM_SRCS := 11 | C_SRCS := 12 | CPP_SRCS := 13 | O_SRCS := 14 | S_UPPER_SRCS := 15 | CC_DEPS := 16 | C++_DEPS := 17 | EXECUTABLES := 18 | OBJS := 19 | C_UPPER_DEPS := 20 | CXX_DEPS := 21 | C_DEPS := 22 | CPP_DEPS := 23 | 24 | # Every subdirectory with source files must be described here 25 | SUBDIRS := \ 26 | src \ 27 | 28 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/src/DisplayNixie.d: -------------------------------------------------------------------------------- 1 | src/DisplayNixie.d: ../src/DisplayNixie.cpp 2 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/src/DisplayNixie.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afch/NixieClockRaspberryPi/5323e4237122f357d74b5dfc87b8c75d31e76df2/Firmware NCS318/DisplayNixie/Debug/src/DisplayNixie.o -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/Debug/src/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../src/DisplayNixie.cpp 8 | 9 | OBJS += \ 10 | ./src/DisplayNixie.o 11 | 12 | CPP_DEPS += \ 13 | ./src/DisplayNixie.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/%.o: ../src/%.cpp 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: Cross G++ Compiler' 20 | g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Firmware NCS318/DisplayNixie/src/DisplayNixie.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : DisplayNixie.cpp 3 | // Author : GRA&AFCH 4 | // Version : v1.4 5 | // Copyright : Free 6 | // Description : Display time on shields NCS318 v1.1 7 | //============================================================================ 8 | 9 | #define _VERSION "1.4" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | using namespace std; 21 | #define LEpin 3 22 | #define UP_BUTTON_PIN 1 23 | #define DOWN_BUTTON_PIN 4 24 | #define MODE_BUTTON_PIN 5 25 | #define BUZZER_PIN 0 26 | #define DS1307_ADDRESS 0x68 27 | #define RV_3028_ADDRESS 0x52 28 | uint8_t RTC_Address; 29 | #define I2CFlush 0 30 | 31 | #define DEBOUNCE_DELAY 150 32 | #define TOTAL_DELAY 17 33 | 34 | #define SECOND_REGISTER 0x0 35 | #define MINUTE_REGISTER 0x1 36 | #define HOUR_REGISTER 0x2 37 | #define WEEK_REGISTER 0x3 38 | #define DAY_REGISTER 0x4 39 | #define MONTH_REGISTER 0x5 40 | #define YEAR_REGISTER 0x6 41 | 42 | //#define RED_LIGHT_PIN 28 43 | //#define GREEN_LIGHT_PIN 27 44 | //#define BLUE_LIGHT_PIN 29 45 | #define MAX_POWER 100 46 | 47 | #define UPPER_DOTS_MASK 0x80000000 48 | #define LOWER_DOTS_MASK 0x40000000 49 | 50 | #define LEFT_REPR_START 5 51 | #define LEFT_BUFFER_START 0 52 | #define RIGHT_REPR_START 2 53 | #define RIGHT_BUFFER_START 4 54 | 55 | uint16_t SymbolArray[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; 56 | 57 | int fileDesc; 58 | int redLight = 100; 59 | int greenLight = 0; 60 | int blueLight = 0; 61 | int lightCycle = 0; 62 | bool dotState = 0; 63 | int rotator = 0; 64 | 65 | int bcdToDec(int val) { 66 | return ((val / 16 * 10) + (val % 16)); 67 | } 68 | 69 | int decToBcd(int val) { 70 | return ((val / 10 * 16) + (val % 10)); 71 | } 72 | 73 | tm addHourToDate(tm date) { 74 | date.tm_hour += 1; 75 | mktime(&date); 76 | return date; 77 | } 78 | 79 | tm addMinuteToDate(tm date) { 80 | date.tm_min += 1; 81 | mktime(&date); 82 | return date; 83 | } 84 | 85 | tm getRTCDate() { 86 | wiringPiI2CWrite(fileDesc, I2CFlush); 87 | tm date; 88 | date.tm_sec = bcdToDec(wiringPiI2CReadReg8(fileDesc,SECOND_REGISTER)); 89 | date.tm_min = bcdToDec(wiringPiI2CReadReg8(fileDesc,MINUTE_REGISTER)); 90 | date.tm_hour = bcdToDec(wiringPiI2CReadReg8(fileDesc,HOUR_REGISTER)); 91 | date.tm_wday = bcdToDec(wiringPiI2CReadReg8(fileDesc,WEEK_REGISTER)); 92 | date.tm_mday = bcdToDec(wiringPiI2CReadReg8(fileDesc,DAY_REGISTER)); 93 | date.tm_mon = bcdToDec(wiringPiI2CReadReg8(fileDesc,MONTH_REGISTER)); 94 | date.tm_year = bcdToDec(wiringPiI2CReadReg8(fileDesc,YEAR_REGISTER)); 95 | date.tm_isdst = 0; 96 | return date; 97 | } 98 | 99 | void updateRTCHour(tm date) { 100 | wiringPiI2CWrite(fileDesc, I2CFlush); 101 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 102 | wiringPiI2CWrite(fileDesc, I2CFlush); 103 | } 104 | 105 | void updateRTCMinute(tm date) { 106 | wiringPiI2CWrite(fileDesc, I2CFlush); 107 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 108 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 109 | wiringPiI2CWrite(fileDesc, I2CFlush); 110 | } 111 | void resetRTCSecond() { 112 | wiringPiI2CWrite(fileDesc, I2CFlush); 113 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER, 0); 114 | wiringPiI2CWrite(fileDesc, I2CFlush); 115 | } 116 | 117 | void writeRTCDate(tm date) { 118 | wiringPiI2CWrite(fileDesc, I2CFlush); 119 | wiringPiI2CWriteReg8(fileDesc,SECOND_REGISTER,decToBcd(date.tm_sec)); 120 | wiringPiI2CWriteReg8(fileDesc,MINUTE_REGISTER,decToBcd(date.tm_min)); 121 | wiringPiI2CWriteReg8(fileDesc,HOUR_REGISTER,decToBcd(date.tm_hour)); 122 | wiringPiI2CWriteReg8(fileDesc,WEEK_REGISTER,decToBcd(date.tm_wday)); 123 | wiringPiI2CWriteReg8(fileDesc,DAY_REGISTER,decToBcd(date.tm_mday)); 124 | wiringPiI2CWriteReg8(fileDesc,MONTH_REGISTER,decToBcd(date.tm_mon)); 125 | wiringPiI2CWriteReg8(fileDesc,YEAR_REGISTER,decToBcd(date.tm_year)); 126 | wiringPiI2CWrite(fileDesc, I2CFlush); 127 | } 128 | 129 | void initPin(int pin) { 130 | pinMode(pin, INPUT); 131 | pullUpDnControl(pin, PUD_UP); 132 | 133 | } 134 | 135 | void funcMode(void) { 136 | static unsigned long modeTime = 0; 137 | if ((millis() - modeTime) > DEBOUNCE_DELAY) { 138 | puts("MODE button was pressed."); 139 | resetRTCSecond(); 140 | modeTime = millis(); 141 | } 142 | } 143 | 144 | uint32_t get32Rep(char * _stringToDisplay, int start) { 145 | uint32_t var32 = 0; 146 | 147 | var32= (SymbolArray[_stringToDisplay[start]-0x30])<<20; 148 | var32|=(SymbolArray[_stringToDisplay[start - 1]-0x30])<<10; 149 | var32|=(SymbolArray[_stringToDisplay[start - 2]-0x30]); 150 | return var32; 151 | } 152 | 153 | void fillBuffer(uint32_t var32, unsigned char * buffer, int start) { 154 | buffer[start] = var32>>24; 155 | buffer[start + 1] = var32>>16; 156 | buffer[start + 2] = var32>>8; 157 | buffer[start + 3] = var32; 158 | } 159 | 160 | void dotBlink() 161 | { 162 | static unsigned int lastTimeBlink=millis(); 163 | 164 | if ((millis() - lastTimeBlink) > 1000) 165 | { 166 | lastTimeBlink=millis(); 167 | dotState = !dotState; 168 | } 169 | } 170 | /* 171 | void rotateFireWorks() { 172 | int fireworks[] = {0,0,1, 173 | -1,0,0, 174 | 0,1,0, 175 | 0,0,-1, 176 | 1,0,0, 177 | 0,-1,0 178 | }; 179 | redLight += fireworks[rotator * 3]; 180 | greenLight += fireworks[rotator * 3 + 1]; 181 | blueLight += fireworks[rotator * 3 + 2]; 182 | softPwmWrite(RED_LIGHT_PIN, redLight); 183 | softPwmWrite(GREEN_LIGHT_PIN, greenLight); 184 | softPwmWrite(BLUE_LIGHT_PIN, blueLight); 185 | lightCycle = lightCycle + 1; 186 | if (lightCycle == MAX_POWER) { 187 | rotator = rotator + 1; 188 | lightCycle = 0; 189 | } 190 | if (rotator > 5) 191 | rotator = 0; 192 | }*/ 193 | 194 | uint32_t addBlinkTo32Rep(uint32_t var) { 195 | if (dotState) 196 | { 197 | var &=~LOWER_DOTS_MASK; 198 | var &=~UPPER_DOTS_MASK; 199 | } 200 | else 201 | { 202 | var |=LOWER_DOTS_MASK; 203 | var |=UPPER_DOTS_MASK; 204 | } 205 | return var; 206 | } 207 | 208 | 209 | void RTC_Test() 210 | { 211 | uint8_t errorCounter = 0; 212 | int8_t DS3231InternalTemperature = 0; 213 | RTC_Address = DS1307_ADDRESS; 214 | fileDesc = wiringPiI2CSetup(RTC_Address); 215 | 216 | DS3231InternalTemperature = wiringPiI2CReadReg16(fileDesc, 0x11); 217 | wiringPiI2CWrite(fileDesc, I2CFlush); 218 | 219 | printf("DS3231_T=%i\n\r", DS3231InternalTemperature); 220 | if ((DS3231InternalTemperature < 5) || (DS3231InternalTemperature > 60)) 221 | { 222 | errorCounter++; 223 | RTC_Address = RV_3028_ADDRESS; 224 | } 225 | 226 | fileDesc = wiringPiI2CSetup(RTC_Address); 227 | 228 | if (wiringPiI2CReadReg8(fileDesc, 28) <= 0) 229 | { 230 | errorCounter++; 231 | } 232 | 233 | if (errorCounter == 2) 234 | { 235 | puts("Faulty RTC!"); 236 | return; 237 | } 238 | 239 | wiringPiI2CWrite(fileDesc, 0x0F); 240 | wiringPiI2CWrite(fileDesc, 0x08); 241 | wiringPiI2CWrite(fileDesc, 0x37); 242 | wiringPiI2CWrite(fileDesc, 0x1C); 243 | wiringPiI2CWrite(fileDesc, 0x27); 244 | wiringPiI2CWrite(fileDesc, 0x00); 245 | wiringPiI2CWrite(fileDesc, 0x27); 246 | wiringPiI2CWrite(fileDesc, 0x11); 247 | wiringPiI2CWrite(fileDesc, 0x0F); 248 | wiringPiI2CWrite(fileDesc, 0x00); 249 | wiringPiI2CWrite(fileDesc, 0x0E); 250 | wiringPiI2CWrite(fileDesc, 0x00); 251 | } 252 | 253 | int main(int argc, char* argv[]) { 254 | printf("Nixie Clock v%s \n\r", _VERSION); 255 | wiringPiSetup(); 256 | //softToneCreate (BUZZER_PIN); 257 | //softToneWrite(BUZZER_PIN, 1000); 258 | 259 | /*softPwmCreate(RED_LIGHT_PIN, 100, MAX_POWER); 260 | softPwmCreate(GREEN_LIGHT_PIN, 0, MAX_POWER); 261 | softPwmCreate(BLUE_LIGHT_PIN, 0, MAX_POWER); 262 | */ 263 | initPin(UP_BUTTON_PIN); 264 | initPin(DOWN_BUTTON_PIN); 265 | initPin(MODE_BUTTON_PIN); 266 | //wiringPiISR(MODE_BUTTON_PIN,INT_EDGE_RISING,&funcMode); 267 | RTC_Test(); 268 | fileDesc = wiringPiI2CSetup(RTC_Address); 269 | 270 | tm date = getRTCDate(); 271 | time_t seconds = time(NULL); 272 | tm* timeinfo = localtime (&seconds); 273 | date.tm_mday = timeinfo->tm_mday; 274 | date.tm_wday = timeinfo->tm_wday; 275 | date.tm_mon = timeinfo->tm_mon + 1; 276 | date.tm_year = timeinfo->tm_year - 100; 277 | writeRTCDate(date); 278 | 279 | if (wiringPiSPISetupMode (0, 2000000, 2)) { 280 | puts("SPI ok"); 281 | } 282 | else { 283 | puts("SPI NOT ok"); 284 | return 0; 285 | } 286 | 287 | long hourDelay = millis(); 288 | long minuteDelay = hourDelay; 289 | long modeDelay=hourDelay; 290 | do { 291 | char _stringToDisplay[8]; 292 | date = getRTCDate(); 293 | char* format ="%H%M%S"; 294 | strftime(_stringToDisplay, 8, format, &date); 295 | 296 | //printf("string=%s \n\r", _stringToDisplay); 297 | 298 | pinMode(LEpin, OUTPUT); 299 | dotBlink(); 300 | 301 | unsigned char buff[8]; 302 | 303 | uint32_t var32 = get32Rep(_stringToDisplay, LEFT_REPR_START); 304 | var32 = addBlinkTo32Rep(var32); 305 | fillBuffer(var32, buff , LEFT_BUFFER_START); 306 | 307 | var32 = get32Rep(_stringToDisplay, RIGHT_REPR_START); 308 | var32 = addBlinkTo32Rep(var32); 309 | fillBuffer(var32, buff , RIGHT_BUFFER_START); 310 | 311 | if (digitalRead(UP_BUTTON_PIN) == 0 && (millis() - hourDelay) > DEBOUNCE_DELAY) { 312 | updateRTCHour(addHourToDate(date)); 313 | hourDelay = millis(); 314 | } 315 | if (digitalRead(DOWN_BUTTON_PIN) == 0 && (millis() - minuteDelay) > DEBOUNCE_DELAY) { 316 | updateRTCMinute(addMinuteToDate(date)); 317 | minuteDelay = millis(); 318 | } 319 | 320 | if (digitalRead(MODE_BUTTON_PIN) == 0 && (millis() - modeDelay) > DEBOUNCE_DELAY) { 321 | resetRTCSecond(); 322 | modeDelay = millis(); 323 | } 324 | 325 | //rotateFireWorks(); 326 | digitalWrite(LEpin, LOW); 327 | wiringPiSPIDataRW(0, buff, 8); 328 | digitalWrite(LEpin, HIGH); 329 | delay (TOTAL_DELAY); 330 | } 331 | while (true); 332 | return 0; 333 | } 334 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NixieClockRaspberryPi 2 | Simple Nixie Tubes Clock Based on RaspberryPi, adapter and NCS314-6 Tubes or NCS318-6 Tubes shield for Arduino (by GRA and AFCH). 3 | 4 | A simple program that show the current time (stored in shield's onboard RTC) at Nixie tubes. 5 | 6 | (Enhanced mod by Leon Shaner available here: https://github.com/UberEclectic/NixieClockRaspberryPi/tree/master/DisplayNixie) 7 | 8 | Requared hardware: 9 | 1) Raspberry Pi any models with 40-pin GPIO connector (Except A and B models). 10 | 2) Arduino to Raspberry Pi adapter (by GRA & AFCH): https://gra-afch.com/catalog/shield-nixie-clock-for-arduino/raspberry-pi-shield-nixie-tubes-clock-ncs314-for-in-14-nixie-tubes-options-tubes-gps-remote-arduino-columns-copy/ 11 | 3) Arduino Nixie Clock Shield NCS314 (v1.2, v2.x, v3.x) or NCS318: https://gra-afch.com/catalog/shield-nixie-clock-for-arduino/nixie-tubes-clock-arduino-shield-ncs314-for-xussr-in-14-nixie-tubes/ 12 | 13 | How to use binaries: 14 | 15 | 1) Download and unzip. 16 | 2) Set execute permission "Anyone" to "DisplayNixie" file: https://photos.app.goo.gl/yVWtZkcIU9afhsvI2 17 | 3) Enable SPI and I2C modules in the "Raspberry Pi Configuration": https://photos.app.goo.gl/vH7DtG9nwMzJHwvP2 18 | 3.1) or CLI way "sudo raspi-config": https://photos.app.goo.gl/wfoPd8CNLSlJ0bF83 19 | 4) Run the program "sudo /home/pi/Downloads/NixieClockRaspberryPi-master/Firmware/Debug/DisplayNixie": 20 | https://photos.google.com/album/AF1QipPrdCjy8WkSl1f51m8EP9go7VUFAiGsy_bjW9pH/photo/AF1QipPch7Yz6RWZKBhiU_U8SIZtXHFvxyfVzh27Byjp 21 | 22 | Step-by-Step video: https://youtu.be/-58clsFwA3I 23 | 24 | Сommand line options available for CLITool (/home/pi/Downloads/NixieClockRaspberryPi-master/CLITool/Debug/CLITool): 25 | 1) 123456 - any 6 digits. Shield will display these numbers. 26 | 2) now - Shield will display current system time at the time the command is executed. 27 | 3) clock - the program will loop and will update every second the time from Real Time Clock (RTC on shield board) on tubes. 28 | 4) settime x - set time, where x time in format [hh:mm:ss]. 29 | 5) setsystime - set current time from OS. 30 | Example: "sudo /home/pi/Downloads/NixieClockRaspberryPi-master/CLITool/Debug/CLITool 123456" - will show 123456 on tubes. 31 | 32 | To compile the source: 33 | 34 | Add folder "DisplayNixie" into the workspace of Eclipse: 35 | "File"->"Import", "Genral"->"Existing Project into Workspce". 36 | p.s. The project uses the "wiringPi" library: http://wiringpi.com/download-and-install/ 37 | 38 | Autorun the program at startup: 39 | Edit /home/pi/.bashrc file - add string like this: 40 | sudo "/home/pi/Documents/Eclipse Projects/DisplayNixie/Debug/DisplayNixie" clock 41 | --------------------------------------------------------------------------------