This commit is contained in:
workinghard
2015-04-23 20:26:07 -07:00
parent 8b0bc362fa
commit 0aa31c0565
13 changed files with 193 additions and 29 deletions

View File

@@ -2,9 +2,22 @@
// Animations.swift // Animations.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 07.04.15. // Created by Nikolai Rinas on 07.04.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
// Constants // Constants
let AnimName = "AnimName" let AnimName = "AnimName"
@@ -44,6 +57,8 @@ class Animations: NSObject {
let minFrameSpeed = 100 // the fastest possible speed allowed let minFrameSpeed = 100 // the fastest possible speed allowed
let frameSpeedStep = 100 // how fast increase or decrease speed let frameSpeedStep = 100 // how fast increase or decrease speed
// var _playSendDelay: NSTimeInterval = 0.5 // 500 milliseconds as default // var _playSendDelay: NSTimeInterval = 0.5 // 500 milliseconds as default
var _copyFrameBuffer: [UInt8] = [UInt8]()
override init() { override init() {
super.init() super.init()
@@ -53,6 +68,10 @@ class Animations: NSObject {
self.addAnimation() self.addAnimation()
// Set visible animation // Set visible animation
_animationSelected = 0 _animationSelected = 0
// Init Buffer
for ( var i = 0; i < 64 ; ++i ) {
_copyFrameBuffer.append(255)
}
} }
// How much animations do we have // How much animations do we have
@@ -286,9 +305,21 @@ class Animations: NSObject {
} }
func clearLEDColor() { func clearLEDColor() {
var myByte: [UInt8] = [255] //var myByte: [UInt8] = [255]
let myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData let myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
myData.replaceBytesInRange(NSMakeRange((self.getAnimationFrameID()-1)*64, 64), withBytes: _emptyFrame) myData.replaceBytesInRange(NSMakeRange((self.getAnimationFrameID()-1)*64, 64), withBytes: _emptyFrame)
} }
func copyDisplayedFrame() {
let myData = self.getAnimDataSelected()
var animFrameCount = (self.getAnimationFrameID()-1)*64
for ( var i = 0 ; i < 64 ; ++i ) {
_copyFrameBuffer[i] = myData[animFrameCount]
++animFrameCount
}
}
func pasteDisplayedFrame() {
let myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
myData.replaceBytesInRange(NSMakeRange((self.getAnimationFrameID()-1)*64, 64), withBytes: _copyFrameBuffer)
}
} }

View File

@@ -2,9 +2,21 @@
// ProjectController.swift // ProjectController.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 02.04.15. // Created by Nikolai Rinas on 02.04.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import Cocoa import Cocoa
import Foundation import Foundation

View File

@@ -2,9 +2,21 @@
// AppDelegate.swift // AppDelegate.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 27.03.15. // Created by Nikolai Rinas on 27.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import Cocoa import Cocoa
@@ -144,11 +156,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTextFieldDelegate {
} }
@IBAction func cmdCopyPressed(send: AnyObject) { @IBAction func cmdCopyPressed(send: AnyObject) {
println("cmd c pressed") __animations.copyDisplayedFrame()
} }
@IBAction func cmdPastePressed(send: AnyObject) { @IBAction func cmdPastePressed(send: AnyObject) {
println("cmd v pressed") __animations.pasteDisplayedFrame()
_gameView.updateLEDFrame()
// Send updated frame
__animations.sendFrame()
}
@IBAction func clearLEDs(send: AnyObject) {
// Remove from Memory
__animations.clearLEDColor()
// Update visual
_gameView.updateLEDFrame()
// Update on a hardware
__animations.sendFrame()
} }
} }

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7531"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
<plugIn identifier="com.apple.SceneKitIBPlugin" version="7531"/> <plugIn identifier="com.apple.SceneKitIBPlugin" version="7702"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -159,9 +159,9 @@
<action selector="cmdPastePressed:" target="494" id="DVw-0V-wp5"/> <action selector="cmdPastePressed:" target="494" id="DVw-0V-wp5"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="Clear All" id="202"> <menuItem title="Clear Frame" keyEquivalent="r" id="202">
<connections> <connections>
<action selector="delete:" target="-1" id="235"/> <action selector="clearLEDs:" target="494" id="3lJ-Lc-QCa"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="Select All" keyEquivalent="a" id="198"> <menuItem title="Select All" keyEquivalent="a" id="198">

View File

@@ -2,9 +2,21 @@
// CubeNetwork.cpp // CubeNetwork.cpp
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 28.03.15. // Created by Nikolai Rinas on 28.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#include "CubeNetwork.h" #include "CubeNetwork.h"

View File

@@ -2,9 +2,21 @@
// CubeNetwork.h // CubeNetwork.h
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 28.03.15. // Created by Nikolai Rinas on 28.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#ifndef __Cube4Fun__CubeNetwork__ #ifndef __Cube4Fun__CubeNetwork__
#define __Cube4Fun__CubeNetwork__ #define __Cube4Fun__CubeNetwork__

View File

@@ -2,9 +2,21 @@
// GameView.swift // GameView.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 27.03.15. // Created by Nikolai Rinas on 27.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import SceneKit import SceneKit

View File

@@ -2,9 +2,21 @@
// GameViewController.swift // GameViewController.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 27.03.15. // Created by Nikolai Rinas on 27.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import SceneKit import SceneKit
import QuartzCore import QuartzCore

View File

@@ -1,10 +1,21 @@
// //
// ObjCtoCPlusPlus.h // ObjCtoCPlusPlus.h
// Performance_Console
// //
// Created by Gian Luigi Romita on 12/06/14. // Created by Nikolai Rinas on 02/02/2015.
// Copyright (c) 2014 Gian Luigi Romita. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>

View File

@@ -1,3 +1,17 @@
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
#import "ObjCtoCPlusPlus.h" #import "ObjCtoCPlusPlus.h"
#import "CubeNetwork.h" #import "CubeNetwork.h"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -2,9 +2,21 @@
// Preferences.swift // Preferences.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 18.04.15. // Created by Nikolai Rinas on 18.04.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import Foundation import Foundation

View File

@@ -2,9 +2,21 @@
// PrimitivesScene.swift // PrimitivesScene.swift
// Cube4Fun // Cube4Fun
// //
// Created by Nik on 27.03.15. // Created by Nikolai Rinas on 27.03.15.
// Copyright (c) 2015 DerNik. All rights reserved. // Copyright (c) 2015 Nikolai Rinas. All rights reserved.
// //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
import Cocoa import Cocoa
import SceneKit import SceneKit