I've been working on a project to hack and communicate with a Gameboy Printer using Microsofts .NET gadgeteer modules. Up until now I was dealing with hardware (see this thread: http://www.tinyclr.com/forum/21/6665/)
I've wired the printer up as an SPI serial connection as required, and now I need to start swapping byte packages with the printer to start exploring printing.
I've made an attempt to put some code together but I've failed miserably. I can't really figure out how to speak to the printer. The only progress I've made is the SPI config, but the actual communication is beyond what I can understand. Perhaps someone can't point me in the right direction?
Here is the code I am trying to somewhat replicate: http://milesburton.com/images/e/ec/GBPrinter_Arduino_Alpha_0.01.pde
My main references are Thermaldotnet (a lib for the sparkfun printer) github.com/yukimizake/ThermalDotNet
SPI on Spider: tinyclr.com/forum/21/6621/
and a basic SPI example: *wiki.tinyclr.com/index.php?title=SPI_-_MP3_Decoder*
How can I see the byte transfer to tell if anything is actually working?
what I have so far:
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Hardware;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace printTherm
{
public partial class Program
{
static SPI MySPI = null;
public static void Sub()
{
InputPort Therm;
Therm = new InputPort(Cpu.Pin.GPIO_Pin8, false, Port.ResistorMode.PullUp);
SPI.Configuration MyConfig =
new SPI.Configuration(Cpu.Pin.GPIO_Pin8,
false, 0, 0, true, true, 1000, SPI.SPI_module.SPI1);
MySPI = new SPI(MyConfig);
bool exit = false;
do
{
byte[] tx_data = new byte[1];
byte[] rx_data = new byte[0];
while (Therm.Read() == true) ;
tx_data[0] = 0x01;
tx_data[1] = 0x00;
MySPI.WriteRead(tx_data, rx_data);
while (Therm.Read() == false) ;
byte[] tx_data2 = new byte[28];
byte[] rx_data2 = new byte[28];
for (int i = 0; i < 28; i++)
{
tx_data2[i] = 0xFF;
rx_data2[i] = 0x00;
}
MySPI.WriteRead(tx_data2, rx_data2);
} while (exit == false);
Thread.Sleep(100);
}
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Debug.Print("Program Started");
}
}
}
It's almost exactly the same as the code above, except I've change the Pin to 8 (MISO) and added some array stuff. I'm really just going blind at this point. I feel bad coming into this with such poor knowledge, but any little help would be greatly appreciated.
some more resources for anyone interested in this: full music shield code: code.tinyclr.com/project/330/fez-music-shield/
Documentation: msdn.microsoft.com/en-us/library/ee436313.aspx more documentation: netmf.com/Gadgeteer/docs/GadgeteerCore/2.41.500/html/0d40434b-2a84-2f72-ca4d-b0012535ea58.htm
sorry about the non hyper links + thanks in advance!