Hey, this is crazy, but when you were joking with your landlord, I think he was missing his humor button that day. YOU really need a lawyer involved with this case, especially since the judge cut you off when you were attempting to explain.
In Oklahoma, we call this "railroading" in the justice system. Your landlord knows someone in the court system and he wants you out because he believes he has a liability now.
A letter may help, but because of the ignorance already shown in this case, I think you won't be given much leeway. Seems also that the prosecutor is out of line too. If you were to do some digging I think there would be some "personal" links back to your landlord of family member.
Long term, vacating would be the best deal because "ignorance" is self induced and extremely difficult to battle. But short term, a lawyer would be able to let you keep your plants and maybe even be able to build a better case for a counter civil suit against the landlord and the prosecutor.
You tried once. Don't let them bully you. Even without money, you can plead can't afford an attorney, one will be appointed for you. Not all court appointed attorneys are bad, like the TV points out.
Don't give up, we are here to support you however we can!