Created
June 27, 2012 20:37
-
-
Save zouppen/3006725 to your computer and use it in GitHub Desktop.
LED cube features and animation definitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- |Animation file and LED cube definition. This contains the internal | |
-- representation of the animation. The file format is defined | |
-- elsewhere (TODO). The actual implementation is free to stop if it | |
-- can not scale the data when animation file dimensions differ from | |
-- the LED cube. But you may also implement a scaler, if you will. | |
module Animation where | |
import Data.ByteString (ByteString) | |
-- |Animation file, contains animation dimensions, led counts for each | |
-- dimension. This approach lifts the requirement of equilateral LED | |
-- cube. | |
data Geometry = Geometry { xLeds :: Integer -- ^LED count (horizontal) | |
, yLeds :: Integer -- ^LED count (vertical) | |
, zLeds :: Integer -- ^LED count (depth) | |
, xDim :: Double -- ^Width, relative | |
, yDim :: Double -- ^Height, relative | |
, zDim :: Double -- ^Depth, relative | |
} | |
-- |Single animation. | |
data Animation = Animation { animGeom :: Geometry -- ^Animation geometry | |
, frames :: [Frame] -- ^Frames in successive order | |
} | |
-- |Single frame of animation data. The timestamp is microseconds from | |
-- the beginning of the animation. Voxel array contains the intensity | |
-- data of each voxel. | |
data Frame = Frame { timestamp :: Integer -- ^Timestamp in microseconds | |
, voxels :: VoxelData -- ^Colour map aware format | |
} | |
-- |Voxel data formats are colour map dependent. Currently the only | |
-- supported format is grayscale. | |
data VoxelData = GrayscaleData [Double] | |
-- |The only currently supported colour map type is grayscale. | |
data HardwareType = GrayscaleHw Integer -- ^Colour depth in bits | |
-- |Cube definition. Cube may have different dimensions than the animation file. | |
data Cube = Cube { cubeGeom :: Geometry | |
, hardware :: HardwareType | |
} | |
-- |To minimize memory footprint, the animation data can be processed | |
-- with cube information to produce native format. Native format is | |
-- just a list of frames with no extra fluff. | |
type NativeFormat = [NativeFrame] | |
-- |Native frame has a timestamp when the data is going to be transmitted. | |
data NativeFrame = NativeFrame { nativeTime :: Integer -- ^In microseconds | |
, nativeData :: ByteString -- ^The data on wire | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment